Class: CompilableParameter
- Inherits:
-
Object
- Object
- CompilableParameter
- Defined in:
- lib/compilable_parameter.rb
Defined Under Namespace
Classes: CompilerArgumentError
Instance Attribute Summary collapse
-
#default_value ⇒ Object
readonly
Returns the value of attribute default_value.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #compile(provided_value) ⇒ Object
-
#initialize(option) ⇒ CompilableParameter
constructor
A new instance of CompilableParameter.
Constructor Details
#initialize(option) ⇒ CompilableParameter
Returns a new instance of CompilableParameter.
6 7 8 9 10 11 |
# File 'lib/compilable_parameter.rb', line 6 def initialize(option) option = option.stringify_keys @name = option['name'] @type = option['type'] @default_value = option['default'] end |
Instance Attribute Details
#default_value ⇒ Object (readonly)
Returns the value of attribute default_value.
2 3 4 |
# File 'lib/compilable_parameter.rb', line 2 def default_value @default_value end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/compilable_parameter.rb', line 2 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
2 3 4 |
# File 'lib/compilable_parameter.rb', line 2 def type @type end |
Instance Method Details
#compile(provided_value) ⇒ Object
13 14 15 16 |
# File 'lib/compilable_parameter.rb', line 13 def compile(provided_value) value = provided_value.blank? ? default_value : provided_value process(value) end |