Class: Fig::Statement

Inherits:
Object
  • Object
show all
Defined in:
lib/fig/statement.rb,
lib/fig/statement/asset.rb,
lib/fig/statement/archive.rb,
lib/fig/statement/resource.rb,
lib/fig/statement/environment_variable.rb

Overview

A statement within a package definition file (package.fig).

Defined Under Namespace

Modules: Asset, EnvironmentVariable Classes: Archive, Command, Configuration, GrammarVersion, Include, IncludeFile, Override, Path, Resource, Retrieve, Set, SyntheticRawText

Constant Summary collapse

ENVIRONMENT_VARIABLE_NAME_REGEX =
%r< \A \w+ \z >x

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line_column, source_description) ⇒ Statement

This mess of getting these as a single array necessary is due to limitations of the “*” array splat operator in ruby v1.8.



31
32
33
34
35
36
37
# File 'lib/fig/statement.rb', line 31

def initialize(line_column, source_description)
  if line_column
    @line, @column = *line_column
  end

  @source_description = source_description
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



27
28
29
# File 'lib/fig/statement.rb', line 27

def column
  @column
end

#lineObject (readonly)

Returns the value of attribute line.



27
28
29
# File 'lib/fig/statement.rb', line 27

def line
  @line
end

#source_descriptionObject (readonly)

Returns the value of attribute source_description.



27
28
29
# File 'lib/fig/statement.rb', line 27

def source_description
  @source_description
end

Class Method Details

.position_description(line, column, source_description) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fig/statement.rb', line 11

def self.position_description(line, column, source_description)
  if not line or not column
    return '' if not source_description

    return " (#{source_description})"
  end

  description = " (line #{line}, column #{column}"
  if source_description
    description << ", #{source_description}"
  end
  description << ')'

  return description
end

Instance Method Details

#deparse_as_version(deparser) ⇒ Object



50
51
52
# File 'lib/fig/statement.rb', line 50

def deparse_as_version(deparser)
  raise NotImplementedError.new self.class.name
end

#is_asset?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/fig/statement.rb', line 70

def is_asset?()
  return false
end

#is_environment_variable?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/fig/statement.rb', line 74

def is_environment_variable?()
  return false
end

#minimum_grammar_for_emitting_inputObject

Returns a two element array containing the version and an explanation of why the version is necessary if the version is greater than 0.



56
57
58
# File 'lib/fig/statement.rb', line 56

def minimum_grammar_for_emitting_input()
  raise NotImplementedError.new self.class.name
end

#minimum_grammar_for_publishingObject

Returns a two element array containing the version and an explanation of why the version is necessary if the version is greater than 0.



62
63
64
# File 'lib/fig/statement.rb', line 62

def minimum_grammar_for_publishing()
  raise NotImplementedError.new self.class.name
end

#position_stringObject

Returns a representation of the position of this statement, if the position is known, empty string otherwise. This is written with the idea that you can do something like “puts %Q<Found a statement%Fig::Statement.statementstatement.position_string().>” and get nice looking output regardless of whether the position is actually known or not.



83
84
85
86
87
# File 'lib/fig/statement.rb', line 83

def position_string
  return Fig::Statement.position_description(
    @line, @column, @source_description
  )
end

#statement_typeObject

A name for this kind of Statement, usually a keyword for this statement as it appears in package definition files.



41
42
43
# File 'lib/fig/statement.rb', line 41

def statement_type()
  raise NotImplementedError.new self.class.name
end

#urlsObject



66
67
68
# File 'lib/fig/statement.rb', line 66

def urls()
  return []
end

#walk_statements(&block) ⇒ Object

Block will receive a Statement.



46
47
48
# File 'lib/fig/statement.rb', line 46

def walk_statements(&block)
  return
end