Class: Qipowl::Mappers::BowlerMapper

Inherits:
Mapper show all
Defined in:
lib/qipowl/core/mapper.rb

Direct Known Subclasses

HtmlBowlerMapper

Instance Method Summary collapse

Methods inherited from Mapper

#load_yaml, #merge!, #to_hash

Constructor Details

#initialize(input = nil) ⇒ BowlerMapper

Returns a new instance of BowlerMapper.



52
53
54
55
# File 'lib/qipowl/core/mapper.rb', line 52

def initialize input = nil
  input = self.class.name.split('::').last.downcase.gsub(/bowlermapper\Z/, '') if input.nil?
  super input
end

Instance Method Details

#entitiesObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/qipowl/core/mapper.rb', line 59

def entities
  return @entities unless @entities_dirty
  @entities = {}
  @hash[:entities].each { |key, value| # :block. :alone etc
    @entities[key] ||= {}
    value.each { |k, v|
      # Append keys
      @entities[key][k.bowl] = v.dup
      if Hash === v
        @entities[key][k.bowl].delete(:synonyms) 
        # Append explicit synonyms
        v[:synonyms].each { |syn|
          (@entities[key][syn.bowl] = v.dup).delete(:synonyms)
          @entities[key][syn.bowl][:marker] = k.bowl
        } if v[:synonyms]
      end
    }
  }
  @entities_dirty = false
  @entities
end