Class: Dontbugme::SpanCollection
- Inherits:
-
Object
- Object
- Dontbugme::SpanCollection
show all
- Includes:
- Enumerable
- Defined in:
- lib/dontbugme/span_collection.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of SpanCollection.
7
8
9
|
# File 'lib/dontbugme/span_collection.rb', line 7
def initialize(spans)
@spans = spans.to_a.freeze
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/dontbugme/span_collection.rb', line 23
def method_missing(method_name, *args, &block)
cat = method_name.to_s.downcase.to_sym
return category(cat) if known_category?(cat)
super
end
|
Instance Method Details
#category(cat) ⇒ Object
19
20
21
|
# File 'lib/dontbugme/span_collection.rb', line 19
def category(cat)
@spans.select { |s| s.category == cat.to_sym }
end
|
#count ⇒ Object
15
16
17
|
# File 'lib/dontbugme/span_collection.rb', line 15
def count
@spans.count
end
|
#each(&block) ⇒ Object
11
12
13
|
# File 'lib/dontbugme/span_collection.rb', line 11
def each(&block)
@spans.each(&block)
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
30
31
32
|
# File 'lib/dontbugme/span_collection.rb', line 30
def respond_to_missing?(method_name, include_private = false)
known_category?(method_name.to_s.downcase.to_sym) || super
end
|