Class: Forest::BlockSet
- Inherits:
-
Object
- Object
- Forest::BlockSet
- Defined in:
- app/classes/forest/block_set.rb
Instance Method Summary collapse
- #first_of_kind(block_kind) ⇒ Object
-
#initialize(blocks = [], options = {}) ⇒ BlockSet
constructor
A new instance of BlockSet.
- #kind(block_kinds) ⇒ Object
- #last_of_kind(block_kind) ⇒ Object
Constructor Details
#initialize(blocks = [], options = {}) ⇒ BlockSet
Returns a new instance of BlockSet.
4 5 6 |
# File 'app/classes/forest/block_set.rb', line 4 def initialize(blocks = [], = {}) @blocks = blocks end |
Instance Method Details
#first_of_kind(block_kind) ⇒ Object
19 20 21 |
# File 'app/classes/forest/block_set.rb', line 19 def first_of_kind(block_kind) kind(block_kind).first end |
#kind(block_kinds) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'app/classes/forest/block_set.rb', line 8 def kind(block_kinds) @kind ||= {} block_kinds = Array(block_kinds).collect(&:to_s) @kind[block_kinds] ||= block_kinds @blocks.select do |block| @kind[block_kinds].select do |block_kind| @kind[block_kinds].include?(block.class.name) end.present? end end |
#last_of_kind(block_kind) ⇒ Object
23 24 25 |
# File 'app/classes/forest/block_set.rb', line 23 def last_of_kind(block_kind) kind(block_kind).last end |