Class: Cooltrainer::Atom

Inherits:
Struct
  • Object
show all
Defined in:
lib/distorted-floor/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

Instance Method Summary collapse

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.



111
# File 'lib/distorted-floor/element_of_media/change.rb', line 111

def method_missing(meth, *a, **k, &b); self.get.send(meth, *a, **k, &b); end

Instance Attribute Details

#defaultObject

Returns the value of attribute default

Returns:

  • (Object)

    the current value of default



104
105
106
# File 'lib/distorted-floor/element_of_media/change.rb', line 104

def default
  @default
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



104
105
106
# File 'lib/distorted-floor/element_of_media/change.rb', line 104

def value
  @value
end

Instance Method Details

#getObject

Return a value if set, otherwise a default. Both can be `nil`.



106
# File 'lib/distorted-floor/element_of_media/change.rb', line 106

def get; self.value || self.default; end

#to_sObject

Override these default Struct methods with ones that reference our :get



108
# File 'lib/distorted-floor/element_of_media/change.rb', line 108

def to_s; self.get.to_s; end

#to_strObject

Implicit



109
# File 'lib/distorted-floor/element_of_media/change.rb', line 109

def to_str; self.get.to_s; end