Class: Vulcano::ParsedVariable

Inherits:
Object
  • Object
show all
Defined in:
lib/vulcano/parsed_variable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value, type = nil) ⇒ ParsedVariable

Returns a new instance of ParsedVariable.



7
8
9
10
11
# File 'lib/vulcano/parsed_variable.rb', line 7

def initialize(key, value, type = nil)
  @original_name = key
  @value = value
  @type = type
end

Instance Attribute Details

#original_nameObject (readonly)

Returns the value of attribute original_name.



3
4
5
# File 'lib/vulcano/parsed_variable.rb', line 3

def original_name
  @original_name
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/vulcano/parsed_variable.rb', line 5

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/vulcano/parsed_variable.rb', line 4

def value
  @value
end

Instance Method Details

#arrayObject



17
18
19
# File 'lib/vulcano/parsed_variable.rb', line 17

def array
  ParsedVariable.new(original_name, nil, "[#{type}]")
end

#nameObject



13
14
15
# File 'lib/vulcano/parsed_variable.rb', line 13

def name
  original_name.camel_case_lower
end

#typeString(object) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/vulcano/parsed_variable.rb', line 27

def typeString(object)
  case object
  when Integer then 'Int'
  when Float then 'Float'
  when String then 'String'
  when TrueClass then 'Bool'
  when FalseClass then 'Bool'
  when Hash then original_name.camel_case
  when Array then "[#{typeString(object.first)}]"
  else
    raise "Unknown type: #{object.class}"
  end
end