Class: Mu::Xtractr::Term
- Inherits:
-
Object
- Object
- Mu::Xtractr::Term
- Includes:
- Enumerable
- Defined in:
- lib/mu/xtractr/term.rb,
lib/mu/xtractr/test/tc_term.rb
Overview
end
Defined Under Namespace
Classes: Test
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Return the field containing this term.
-
#frequency ⇒ Object
readonly
Return the (packet) frequency of this term.
-
#value ⇒ Object
readonly
Return the value of this term.
-
#xtractr ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
-
#each_packet(q = nil, &blk) ⇒ Object
(also: #each)
Fetch each packet from the index that has this term in this field.
-
#initialize(field, json) ⇒ Term
constructor
:nodoc:.
-
#inspect ⇒ Object
:nodoc:.
-
#packets(q = nil) ⇒ Object
Return an instance of Packets that serves as an iterator for all packets containing this term.
Constructor Details
#initialize(field, json) ⇒ Term
:nodoc:
41 42 43 44 45 46 |
# File 'lib/mu/xtractr/term.rb', line 41 def initialize field, json # :nodoc: @field = field @xtractr = field.xtractr @value = json['key'] @frequency = json['value'] end |
Instance Attribute Details
#field ⇒ Object (readonly)
Return the field containing this term.
33 34 35 |
# File 'lib/mu/xtractr/term.rb', line 33 def field @field end |
#frequency ⇒ Object (readonly)
Return the (packet) frequency of this term.
39 40 41 |
# File 'lib/mu/xtractr/term.rb', line 39 def frequency @frequency end |
#value ⇒ Object (readonly)
Return the value of this term.
36 37 38 |
# File 'lib/mu/xtractr/term.rb', line 36 def value @value end |
#xtractr ⇒ Object (readonly)
:nodoc:
30 31 32 |
# File 'lib/mu/xtractr/term.rb', line 30 def xtractr @xtractr end |
Instance Method Details
#each_packet(q = nil, &blk) ⇒ Object Also known as: each
Fetch each packet from the index that has this term in this field. If the optional q is specified, the search query is AND’d with the term’s own search query
field.term('mozilla').each { |pkt| ... }
52 53 54 55 56 |
# File 'lib/mu/xtractr/term.rb', line 52 def each_packet(q=nil, &blk) # :yields: packet _q = "#{field.name}:#{value}" _q << " #{q}" if q return Packets.new(xtractr, :q => _q).each(&blk) end |
#inspect ⇒ Object
:nodoc:
66 67 68 |
# File 'lib/mu/xtractr/term.rb', line 66 def inspect # :nodoc: "#<term:#{field.name} #{value} #{frequency}>" end |