Class: Egi::Group
- Inherits:
-
Object
- Object
- Egi::Group
- Defined in:
- lib/egi/group.rb
Instance Method Summary collapse
-
#initialize(name = nil) ⇒ Group
constructor
A new instance of Group.
- #instance_eval(&block) ⇒ Object
- #item(name, hash = {}) ⇒ Object
- #items ⇒ Object
- #set(default) ⇒ Object
Constructor Details
#initialize(name = nil) ⇒ Group
Returns a new instance of Group.
3 4 5 6 |
# File 'lib/egi/group.rb', line 3 def initialize(name = nil) @tags = name ? [ name ] : [ ] @default = {} end |
Instance Method Details
#instance_eval(&block) ⇒ Object
12 13 14 15 |
# File 'lib/egi/group.rb', line 12 def instance_eval(&block) super self # for method chain end |
#item(name, hash = {}) ⇒ Object
21 22 23 24 |
# File 'lib/egi/group.rb', line 21 def item(name, hash = {}) items[name.to_sym].update(hash) self # for method chain end |
#items ⇒ Object
17 18 19 |
# File 'lib/egi/group.rb', line 17 def items @items ||= Hash.new {|hash, key| hash[key] = Item[{ :name => key, :tags => @tags }.merge(@default)] } end |
#set(default) ⇒ Object
8 9 10 |
# File 'lib/egi/group.rb', line 8 def set(default) @default = default end |