Class: Cooltrainer::Atom
- Inherits:
-
Struct
- Object
- Struct
- Cooltrainer::Atom
- Defined in:
- lib/distorted/element_of_media/change.rb
Overview
Struct to wrap just the user and default values for a Compound or just for freeform usage.
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#get ⇒ Object
Return a value if set, otherwise a default.
-
#method_missing(meth, *a, **k, &b) ⇒ Object
Send any unknown message through to a value/default.
-
#to_s ⇒ Object
Override these default Struct methods with ones that reference our :get.
-
#to_str ⇒ Object
Implicit.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *a, **k, &b) ⇒ Object
Send any unknown message through to a value/default.
116 |
# File 'lib/distorted/element_of_media/change.rb', line 116 def method_missing(meth, *a, **k, &b); self.get.send(meth, *a, **k, &b); end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default
109 110 111 |
# File 'lib/distorted/element_of_media/change.rb', line 109 def default @default end |
#value ⇒ Object
Returns the value of attribute value
109 110 111 |
# File 'lib/distorted/element_of_media/change.rb', line 109 def value @value end |
Instance Method Details
#get ⇒ Object
Return a value if set, otherwise a default. Both can be ‘nil`.
111 |
# File 'lib/distorted/element_of_media/change.rb', line 111 def get; self.value || self.default; end |
#to_s ⇒ Object
Override these default Struct methods with ones that reference our :get
113 |
# File 'lib/distorted/element_of_media/change.rb', line 113 def to_s; self.get.to_s; end |
#to_str ⇒ Object
Implicit
114 |
# File 'lib/distorted/element_of_media/change.rb', line 114 def to_str; self.get.to_s; end |