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.
56 57 58 |
# File 'lib/directed_edge.rb', line 56 def initialize(type) @type = type end |
Instance Method Details
#[](key) ⇒ Object
59 60 61 62 |
# File 'lib/directed_edge.rb', line 59 def [](key) self[key] = @type.new unless include? key super(key) end |
#each ⇒ Object
63 64 65 |
# File 'lib/directed_edge.rb', line 63 def each super { |key, value| yield(key, value) unless value.empty? } end |
#empty? ⇒ Boolean
66 67 68 |
# File 'lib/directed_edge.rb', line 66 def empty? each { |key, value| return false } ; true end |