Class: Cooltrainer::Atom

Inherits:
Struct
  • Object
show all
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

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.



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

#defaultObject

Returns the value of attribute default

Returns:

  • (Object)

    the current value of default



109
110
111
# File 'lib/distorted/element_of_media/change.rb', line 109

def default
  @default
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



109
110
111
# File 'lib/distorted/element_of_media/change.rb', line 109

def value
  @value
end

Instance Method Details

#getObject

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_sObject

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_strObject

Implicit



114
# File 'lib/distorted/element_of_media/change.rb', line 114

def to_str; self.get.to_s; end