Module: RDF::Countable
- Extended by:
- Util::Aliasing::LateBound
- Included in:
- Enumerator, Enumerable, Graph
- Defined in:
- lib/rdf/mixin/countable.rb
Overview
Defined Under Namespace
Classes: Enumerator
Instance Method Summary collapse
-
#count ⇒ Integer
(also: #size)
Returns the number of RDF statements in ‘self`.
-
#empty? ⇒ Boolean
Returns ‘true` if `self` contains no RDF statements.
- #enum_for(method = :each, *args) ⇒ Enumerator (also: #to_enum)
Methods included from Util::Aliasing::LateBound
Instance Method Details
#count ⇒ Integer Also known as: size
Returns the number of RDF statements in ‘self`.
25 26 27 28 29 |
# File 'lib/rdf/mixin/countable.rb', line 25 def count count = 0 each { count += 1 } count end |
#empty? ⇒ Boolean
Returns ‘true` if `self` contains no RDF statements.
16 17 18 19 |
# File 'lib/rdf/mixin/countable.rb', line 16 def empty? each {return false} true end |
#enum_for(method = :each, *args) ⇒ Enumerator Also known as: to_enum
37 38 39 40 41 42 43 |
# File 'lib/rdf/mixin/countable.rb', line 37 def enum_for(method = :each, *args) # Ensure that enumerators support the `#empty?` and `#count` methods: this = self Countable::Enumerator.new do |yielder| this.send(method, *args) {|y| yielder << y} end end |