Class: LLT::DbHandler::Stub

Inherits:
CommonDb
  • Object
show all
Extended by:
Helpers::Normalizer
Defined in:
lib/llt/db_handler/stub.rb

Defined Under Namespace

Classes: StubEntries

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.stemsObject (readonly)

Returns the value of attribute stems.



13
14
15
# File 'lib/llt/db_handler/stub.rb', line 13

def stems
  @stems
end

Class Method Details

.create_stem_stub(return_val, args) ⇒ Object Also known as: create



15
16
17
18
# File 'lib/llt/db_handler/stub.rb', line 15

def create_stem_stub(return_val, args)
  args = normalize_args(args)
  @stems[args] = return_val
end

.setupObject



21
22
23
# File 'lib/llt/db_handler/stub.rb', line 21

def setup
  StubEntries.setup
end

Instance Method Details

#args_to_queryObject



52
53
54
# File 'lib/llt/db_handler/stub.rb', line 52

def args_to_query
  {type: @args[:type], @args[:stem_type] => @args[:stem] }
end

#direct_lookup(type, string) ⇒ Object



41
42
43
44
45
46
# File 'lib/llt/db_handler/stub.rb', line 41

def direct_lookup(type, string)
  args = dl_to_query(type, string)
  stems.select do |stored|
    stored.merge(args) == stored
  end.values
end

#dl_to_query(type, string) ⇒ Object



48
49
50
# File 'lib/llt/db_handler/stub.rb', line 48

def dl_to_query(type, string)
  { type: type, word: string}
end

#look_up_stem(args) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/llt/db_handler/stub.rb', line 30

def look_up_stem(args)
  super
  stems.select do |stored_args|
    if stored_args.merge(args_to_query) == stored_args
      if restr = @args[:restrictions]
        restr[:values].include?(stored_args[restr[:type]])
      end
    end
  end.values
end

#stemsObject



56
57
58
# File 'lib/llt/db_handler/stub.rb', line 56

def stems
  self.class.stems
end

#typeObject



26
27
28
# File 'lib/llt/db_handler/stub.rb', line 26

def type
  :stub
end