Class: Specifind::Operator

Inherits:
Object
  • Object
show all
Defined in:
lib/specifind/operator.rb

Overview

The data are held in the class definition as a list of identifying Strings.

Constant Summary collapse

@@operators_data =
%w(_and_)
@@operators =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Operator

Returns a new instance of Operator.



34
35
36
37
# File 'lib/specifind/operator.rb', line 34

def initialize(args)
  @pattern = args[:pattern]
  Operator.operators << self
end

Instance Attribute Details

#patternObject

Returns the value of attribute pattern.



9
10
11
# File 'lib/specifind/operator.rb', line 9

def pattern
  @pattern
end

Class Method Details

.find(s) ⇒ Object

find an operator object based on identifying string



29
30
31
32
# File 'lib/specifind/operator.rb', line 29

def self.find(s)
  @@operators.each{|o| return o if o.pattern == s}
  nil
end

.operatorsObject

list of operator objects



12
13
14
# File 'lib/specifind/operator.rb', line 12

def self.operators
  @@operators
end

.operators=(o) ⇒ Object

set list of operator objects



17
18
19
# File 'lib/specifind/operator.rb', line 17

def self.operators=(o)
  @@operators = o
end

.patternsObject

list of operator objects’ patterns



22
23
24
25
26
# File 'lib/specifind/operator.rb', line 22

def self.patterns
  a = []
  @@operators.each{|c| a << c.pattern}
  a
end