Class: ENVied::Variable
- Inherits:
-
Object
- Object
- ENVied::Variable
- Defined in:
- lib/envied/variable.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #default_value(*args) ⇒ Object
-
#initialize(name, type, **options) ⇒ Variable
constructor
A new instance of Variable.
Constructor Details
#initialize(name, type, **options) ⇒ Variable
Returns a new instance of Variable.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/envied/variable.rb', line 4 def initialize(name, type, **) @name = name.to_sym @type = type.to_sym @group = .fetch(:group, :default).to_sym @default = [:default] #if [email protected]_a? String # raise ArgumentError, "Default values should be strings (variable #{@name})" #end end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
2 3 4 |
# File 'lib/envied/variable.rb', line 2 def default @default end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
2 3 4 |
# File 'lib/envied/variable.rb', line 2 def group @group end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/envied/variable.rb', line 2 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
2 3 4 |
# File 'lib/envied/variable.rb', line 2 def type @type end |
Instance Method Details
#==(other) ⇒ Object
19 20 21 22 |
# File 'lib/envied/variable.rb', line 19 def ==(other) self.class == other.class && [name, type, group, default] == [other.name, other.type, other.group, other.default] end |
#default_value(*args) ⇒ Object
15 16 17 |
# File 'lib/envied/variable.rb', line 15 def default_value(*args) default.respond_to?(:call) ? default[*args] : default end |