Class: Vulcano::ParsedVariable
- Inherits:
-
Object
- Object
- Vulcano::ParsedVariable
- Defined in:
- lib/vulcano/parsed_variable.rb
Instance Attribute Summary collapse
-
#original_name ⇒ Object
readonly
Returns the value of attribute original_name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #array ⇒ Object
-
#initialize(key, value, type = nil) ⇒ ParsedVariable
constructor
A new instance of ParsedVariable.
- #name ⇒ Object
- #typeString(object) ⇒ Object
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_name ⇒ Object (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 |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/vulcano/parsed_variable.rb', line 5 def type @type end |
#value ⇒ Object (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
#array ⇒ Object
17 18 19 |
# File 'lib/vulcano/parsed_variable.rb', line 17 def array ParsedVariable.new(original_name, nil, "[#{type}]") end |
#name ⇒ Object
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 |