Class: Aspen::AST::Nodes::Type
- Inherits:
-
Object
- Object
- Aspen::AST::Nodes::Type
- Defined in:
- lib/aspen/ast/nodes/type.rb
Constant Summary collapse
- STRING =
"STRING"
- INTEGER =
"INTEGER"
- FLOAT =
"FLOAT"
- MATCH_FLOAT =
/^([\d,]+\.\d+)$/
- MATCH_INTEGER =
/^([\d,]+)$/
- MATCH_STRING =
/^(.+)$/
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#converter ⇒ Object
readonly
Returns the value of attribute converter.
Class Method Summary collapse
Instance Method Summary collapse
- #get_converter(type_const) ⇒ Object
-
#initialize(type_const) ⇒ Type
constructor
A new instance of Type.
Constructor Details
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
26 27 28 |
# File 'lib/aspen/ast/nodes/type.rb', line 26 def content @content end |
#converter ⇒ Object (readonly)
Returns the value of attribute converter.
26 27 28 |
# File 'lib/aspen/ast/nodes/type.rb', line 26 def converter @converter end |
Class Method Details
.determine(value) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/aspen/ast/nodes/type.rb', line 14 def self.determine(value) new( case value when MATCH_FLOAT then FLOAT when MATCH_INTEGER then INTEGER when MATCH_STRING then STRING else raise ArgumentError, "Could not determine a type for value:\n\t#{value.inspect}" end ) end |
Instance Method Details
#get_converter(type_const) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/aspen/ast/nodes/type.rb', line 33 def get_converter(type_const) case type_const when FLOAT then :to_f when INTEGER then :to_i when STRING then :to_s else raise ArgumentError, "Could not determine a converter method for type:\n\t#{value.inspect}" end end |