Class: Fig::ParserPackageBuildState
- Inherits:
-
Object
- Object
- Fig::ParserPackageBuildState
- Defined in:
- lib/fig/parserpackagebuildstate.rb
Instance Attribute Summary collapse
-
#descriptor ⇒ Object
readonly
Returns the value of attribute descriptor.
-
#source_description ⇒ Object
readonly
Returns the value of attribute source_description.
Instance Method Summary collapse
-
#initialize(descriptor, source_description) ⇒ ParserPackageBuildState
constructor
A new instance of ParserPackageBuildState.
- #new_environment_variable_statement(statement_class, keyword_node, value_node) ⇒ Object
- #node_location(node) ⇒ Object
-
#node_location_description(node) ⇒ Object
This method is necessary due to ruby v1.8 not allowing array splat notation, i.e.
- #raise_invalid_value_parse_error(keyword_node, value_node, description) ⇒ Object
Constructor Details
#initialize(descriptor, source_description) ⇒ ParserPackageBuildState
Returns a new instance of ParserPackageBuildState.
10 11 12 13 |
# File 'lib/fig/parserpackagebuildstate.rb', line 10 def initialize(descriptor, source_description) @descriptor = descriptor @source_description = source_description end |
Instance Attribute Details
#descriptor ⇒ Object (readonly)
Returns the value of attribute descriptor.
7 8 9 |
# File 'lib/fig/parserpackagebuildstate.rb', line 7 def descriptor @descriptor end |
#source_description ⇒ Object (readonly)
Returns the value of attribute source_description.
8 9 10 |
# File 'lib/fig/parserpackagebuildstate.rb', line 8 def source_description @source_description end |
Instance Method Details
#new_environment_variable_statement(statement_class, keyword_node, value_node) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fig/parserpackagebuildstate.rb', line 36 def new_environment_variable_statement( statement_class, keyword_node, value_node ) name, value = statement_class.parse_name_value(value_node.text_value) { raise_invalid_value_parse_error( keyword_node, value_node, statement_class.const_get(:ARGUMENT_DESCRIPTION) ) } return statement_class.new( node_location(keyword_node), source_description, name, value ) end |
#node_location(node) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/fig/parserpackagebuildstate.rb', line 15 def node_location(node) offset_from_start_of_file = node.interval.first input = node.input return [ input.line_of(offset_from_start_of_file), input.column_of(offset_from_start_of_file) ] end |
#node_location_description(node) ⇒ Object
This method is necessary due to ruby v1.8 not allowing array splat notation, i.e. Fig::Statement.position_description(*node_location(node), source_description)
28 29 30 31 32 33 34 |
# File 'lib/fig/parserpackagebuildstate.rb', line 28 def node_location_description(node) location = node_location(node) return Fig::Statement.position_description( location[0], location[1], source_description ) end |
#raise_invalid_value_parse_error(keyword_node, value_node, description) ⇒ Object
51 52 53 54 55 |
# File 'lib/fig/parserpackagebuildstate.rb', line 51 def raise_invalid_value_parse_error(keyword_node, value_node, description) raise Fig::PackageParseError.new( %Q<Invalid value for #{keyword_node.text_value} statement: "#{value_node.text_value}" #{description}#{node_location_description(value_node)}> ) end |