Module: HasAttributes
- Included in:
- IChing::Hexagram, IChing::Line, IChing::Trigram
- Defined in:
- lib/i_ching/has_attributes.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
2 3 4 |
# File 'lib/i_ching/has_attributes.rb', line 2 def attributes @attributes end |
Class Method Details
.included(base) ⇒ Object
9 10 11 |
# File 'lib/i_ching/has_attributes.rb', line 9 def self.included(base) base.extend(self) end |
Instance Method Details
#has_attributes(*args) ⇒ Object
4 5 6 7 |
# File 'lib/i_ching/has_attributes.rb', line 4 def has_attributes(*args) @attributes = args instance_eval { attr_reader *@attributes } end |
#initialize(args) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/i_ching/has_attributes.rb', line 13 def initialize(args) args.each do |k, v| next unless self.class.attributes.include?(k) instance_variable_set("@#{k}", v) end end |