Class: DirectedEdge::CollectionHash
- Inherits:
-
Hash
- Object
- Hash
- DirectedEdge::CollectionHash
- Defined in:
- lib/directed_edge.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #each ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(type) ⇒ CollectionHash
constructor
A new instance of CollectionHash.
Constructor Details
#initialize(type) ⇒ CollectionHash
Returns a new instance of CollectionHash.
59 60 61 |
# File 'lib/directed_edge.rb', line 59 def initialize(type) @type = type end |
Instance Method Details
#[](key) ⇒ Object
62 63 64 65 |
# File 'lib/directed_edge.rb', line 62 def [](key) self[key] = @type.new unless include? key super(key) end |
#each ⇒ Object
66 67 68 |
# File 'lib/directed_edge.rb', line 66 def each super { |key, value| yield(key, value) unless value.empty? } end |
#empty? ⇒ Boolean
69 70 71 |
# File 'lib/directed_edge.rb', line 69 def empty? each { |key, value| return false } ; true end |