class Aspen::AST::Nodes::Type

Constants

FLOAT
INTEGER
MATCH_FLOAT
MATCH_INTEGER
MATCH_STRING
STRING

Attributes

content[R]
converter[R]

Public Class Methods

determine(value) click to toggle source
# 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
new(type_const) click to toggle source
# File lib/aspen/ast/nodes/type.rb, line 28
def initialize(type_const)
  @content   = Aspen::AST::Nodes::Content.new(type_const)
  @converter = get_converter(type_const)
end

Public Instance Methods

get_converter(type_const) click to toggle source
# 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