Class: MoneyHeuristics::Analyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/money-heuristics/analyzer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str, search_tree) ⇒ Analyzer

Returns a new instance of Analyzer.



6
7
8
9
10
11
12
13
# File 'lib/money-heuristics/analyzer.rb', line 6

def initialize(str, search_tree)
  @str = (str || '').dup
  @search_tree = search_tree
  @currencies = []
  @methods = { iso_code: :search_by_iso_code, 
               symbol: :search_by_symbol, 
               name: :search_by_name }
end

Instance Attribute Details

#currenciesObject

Returns the value of attribute currencies.



4
5
6
# File 'lib/money-heuristics/analyzer.rb', line 4

def currencies
  @currencies
end

#methodsObject

Returns the value of attribute methods.



4
5
6
# File 'lib/money-heuristics/analyzer.rb', line 4

def methods
  @methods
end

#search_treeObject (readonly)

Returns the value of attribute search_tree.



3
4
5
# File 'lib/money-heuristics/analyzer.rb', line 3

def search_tree
  @search_tree
end

#strObject

Returns the value of attribute str.



4
5
6
# File 'lib/money-heuristics/analyzer.rb', line 4

def str
  @str
end

#wordsObject (readonly)

Returns the value of attribute words.



3
4
5
# File 'lib/money-heuristics/analyzer.rb', line 3

def words
  @words
end

Instance Method Details

#process(filters) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/money-heuristics/analyzer.rb', line 15

def process(filters)
  format
  return [] if str.empty?

  filter_methods(filters).each { |method| send(method) }

  prepare_reply
end