Module: ODDB::Interval

Included in:
IndexedInterval, State::Admin::Indications, State::Admin::OrphanedFachinfos, State::Admin::OrphanedPatinfos, State::Admin::PatinfoDeprivedSequences, State::Admin::PatinfoStats, State::Companies::CompanyResult, State::Doctors::DoctorList, State::Hospitals::HospitalList, State::Substances::Substances, TestInterval::Stub
Defined in:
src/util/interval.rb

Constant Summary

PERSISTENT_RANGE =
false
RANGE_PATTERNS =
{
  'a-d'      => 'a-dÅÆÄÁÂÀÃĄǍĂĀȦḂÇĈČĆĊḐĐÐĎḊåæäáâàãąǎăāȧḃçĉčćċḑđðďḋ',
  'e-h'      => 'e-hËÉÊÈȨĘĚĔẼĒĖÞḞĢǦĞǴĜḠĠȞĤḦḨḢëéêèȩęěĕẽēėþḟģǧğǵĝḡġȟĥḧḩḣ',
  'i-l'      => 'i-lÏÍÎÌĮǏĬĨİĴǨḰĶŁĹĽĻïíîìįǐĭĩıĵǩḱķłĺľļ',
  'm-p'      => 'm-pḾṀŇŃÑǸŅṄŒÖÓÔÒÕŌŎØǪǑȮṔṖḿṁňńñǹņṅœöóôòõōŏøǫǒȯṕṗ',
  'q-t'      => 'q-tŘŔŖṘŚŜŠŞṠŤŢṪřŕŗṙśŝšşṡťţṫ',
  'u-z'      => 'u-zÜÚÛÙŲǗǓǙǛŨŬŮǕṼẂŴẀẄẆẌẊŸẎỸỲŶÝȲŽŹẐŻüúûùųǘǔǚǜũŭůǖṽẃŵẁẅẇẍẋÿẏỹỳŷýȳžźẑż',
  '|unknown'=> '|unknown',
}
FILTER_THRESHOLD =
30

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) range (readonly)

Returns the value of attribute range



17
18
19
# File 'src/util/interval.rb', line 17

def range
  @range
end

Instance Method Details

- (Object) default_interval



18
19
20
# File 'src/util/interval.rb', line 18

def default_interval
  intervals.first || 'a-d'
end

- (Object) filter_interval



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'src/util/interval.rb', line 21

def filter_interval
  if(@model.size > self::class::FILTER_THRESHOLD)
    ptrns = range_patterns
    @range = ptrns.fetch(user_range) {
      ptrns[default_interval]
    }
    pattern = if(@range=='|unknown')
      /^($|[^a-zÅÆÄÁÂÀÃĄǍĂĀȦḂÇĈČĆĊḐĐÐĎḊËÉÊÈȨĘĚĔẼĒĖÞḞĢǦĞǴĜḠĠȞĤḦḨḢÏÍÎÌĮǏĬĨİĴǨḰĶŁĹĽĻḾṀŇŃÑǸŅṄŒÖÓÔÒÕŌŎØǪǑȮṔṖŘŔŖṘŚŜŠŞṠŤŢṪÜÚÛÙŲǗǓǙǛŨŬŮǕṼẂŴẀẄẆẌẊŸẎỸỲŶÝȲŽŹẐŻåæäáâàãąǎăāȧḃçĉčćċḑđðďḋëéêèȩęěĕẽēėþḟģǧğǵĝḡġȟĥḧḩḣïíîìįǐĭĩıĵǩḱķłĺľļḿṁňńñǹņṅœöóôòõōŏøǫǒȯṕṗřŕŗṙśŝšşṡťţṫüúûùųǘǔǚǜũŭůǖṽẃŵẁẅẇẍẋÿẏỹỳŷýȳžźẑż])/ui
    elsif(@range)
      /^[#{@range}]/ui
    else
      /^$/u
    end
    @filter = Proc.new { |model|
      model.select { |item| 
        pattern.match(item.send(*symbol))
      }
    }
  end
end

- (Object) get_intervals



41
42
43
44
45
46
47
# File 'src/util/interval.rb', line 41

def get_intervals
  @model.collect { |item| 
    range_patterns.collect { |range, pattern| 
      range if /^[#{pattern}]/iu.match(item.send(*symbol))
    }.compact.first || '|unknown'
  }.flatten.uniq.sort
end

- (Object) interval



48
49
50
# File 'src/util/interval.rb', line 48

def interval
  @interval ||= range_patterns.index(@range)
end

- (Object) intervals



51
52
53
# File 'src/util/interval.rb', line 51

def intervals
  @intervals ||= get_intervals
end

- (Object) range_patterns



54
55
56
# File 'src/util/interval.rb', line 54

def range_patterns
  self.class.const_get(:RANGE_PATTERNS)
end

- (Object) symbol



68
69
70
# File 'src/util/interval.rb', line 68

def symbol
  :to_s
end

- (Object) user_range



57
58
59
60
61
62
63
64
65
66
67
# File 'src/util/interval.rb', line 57

def user_range
  range = if(self::class::PERSISTENT_RANGE)
    @session.persistent_user_input(:range)
  else
    @session.user_input(:range)
  end
  unless(intervals.include?(range))
    range = default_interval
  end
  range
end