Class: Diminutivity::Matcher

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namefile = NAMEFILE) ⇒ Matcher

Returns a new instance of Matcher.



10
11
12
13
14
15
16
17
18
# File 'lib/diminutivity.rb', line 10

def initialize(namefile=NAMEFILE)
  self.names = {}
  self.namefile = namefile
  CSV.read(Pathname.new(__FILE__).parent.join("../#{namefile}")).each do |row|
    row.each do |name|
      names[name] = row - [name]
    end
  end
end

Instance Attribute Details

#namefileObject

Returns the value of attribute namefile.



8
9
10
# File 'lib/diminutivity.rb', line 8

def namefile
  @namefile
end

#namesObject

Returns the value of attribute names.



8
9
10
# File 'lib/diminutivity.rb', line 8

def names
  @names
end

Instance Method Details

#match(name, source_name) ⇒ Object



20
21
22
# File 'lib/diminutivity.rb', line 20

def match(name,source_name)
  names[name].include? source_name
end