Class: Fig::Statement
- Inherits:
-
Object
- Object
- Fig::Statement
- Defined in:
- lib/fig/statement.rb,
lib/fig/statement/asset.rb,
lib/fig/statement/archive.rb,
lib/fig/statement/resource.rb
Overview
A statement within a package definition file (package.fig).
Direct Known Subclasses
Archive, Command, Configuration, GrammarVersion, Include, Override, Path, Resource, Retrieve, Set
Defined Under Namespace
Modules: Asset Classes: Archive, Command, Configuration, GrammarVersion, Include, Override, Path, Resource, Retrieve, Set
Constant Summary collapse
- ENVIRONMENT_VARIABLE_NAME_REGEX =
%r< \A \w+ \z >x
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#source_description ⇒ Object
readonly
Returns the value of attribute source_description.
Class Method Summary collapse
- .position_description(line, column, source_description) ⇒ Object
-
.strip_quotes_and_process_escapes!(string, &error_block) ⇒ Object
Parameter will be modified.
Instance Method Summary collapse
-
#initialize(line_column, source_description) ⇒ Statement
constructor
This mess of getting these as a single array necessary is due to limitations of the “*” array splat operator in ruby v1.8.
- #is_asset? ⇒ Boolean
- #is_environment_variable? ⇒ Boolean
- #minimum_grammar_version_required ⇒ Object
-
#position_string ⇒ Object
Returns a representation of the position of this statement, if the position is known, empty string otherwise.
- #unparse_as_version(unparser) ⇒ Object
- #urls ⇒ Object
-
#walk_statements(&block) ⇒ Object
Block will receive a Statement.
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.
146 147 148 149 150 151 152 |
# File 'lib/fig/statement.rb', line 146 def initialize(line_column, source_description) if line_column @line, @column = *line_column end @source_description = source_description end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
11 12 13 |
# File 'lib/fig/statement.rb', line 11 def column @column end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
11 12 13 |
# File 'lib/fig/statement.rb', line 11 def line @line end |
#source_description ⇒ Object (readonly)
Returns the value of attribute source_description.
11 12 13 |
# File 'lib/fig/statement.rb', line 11 def source_description @source_description end |
Class Method Details
.position_description(line, column, source_description) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fig/statement.rb', line 13 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 |
.strip_quotes_and_process_escapes!(string, &error_block) ⇒ Object
Parameter will be modified.
Takes a block that is invoked when there is an error. Block receives a single parameter of an error message that is the end of a statement describing the problem, with no leading space character. For example, given «‘foo», the block will receive a message like ’has unbalanced single quotes.‘.
Returns whether parameter was single-quoted; if there was a parse error, then the return value will be nil (and the block will have been invoked).
39 40 41 42 43 44 45 46 47 |
# File 'lib/fig/statement.rb', line 39 def self.strip_quotes_and_process_escapes!(string, &error_block) return false if string.length == 0 replaced_quotes = strip_single_quotes!(string, &error_block) return true if replaced_quotes return if replaced_quotes.nil? return process_escapes_and_strip_double_quotes!(string, &error_block) end |
Instance Method Details
#is_asset? ⇒ Boolean
171 172 173 |
# File 'lib/fig/statement.rb', line 171 def is_asset?() return false end |
#is_environment_variable? ⇒ Boolean
175 176 177 |
# File 'lib/fig/statement.rb', line 175 def is_environment_variable?() return false end |
#minimum_grammar_version_required ⇒ Object
163 164 165 |
# File 'lib/fig/statement.rb', line 163 def minimum_grammar_version_required() raise NotImplementedError end |
#position_string ⇒ Object
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.
184 185 186 187 188 |
# File 'lib/fig/statement.rb', line 184 def position_string return Fig::Statement.position_description( @line, @column, @source_description ) end |
#unparse_as_version(unparser) ⇒ Object
159 160 161 |
# File 'lib/fig/statement.rb', line 159 def unparse_as_version(unparser) raise NotImplementedError end |
#urls ⇒ Object
167 168 169 |
# File 'lib/fig/statement.rb', line 167 def urls() return [] end |
#walk_statements(&block) ⇒ Object
Block will receive a Statement.
155 156 157 |
# File 'lib/fig/statement.rb', line 155 def walk_statements(&block) return end |