class Ubi::Thema

Thema -> subject, matter, case

Attributes

ascii[RW]
clean[RW]
name[RW]
opts[RW]
urls[RW]

Public Class Methods

new(name, urls = [], opts = {}) click to toggle source
# File lib/ubi/thema.rb, line 12
def initialize(name, urls = [], opts = {})
  @name = name
  @urls = urls
  @name ||= urls.first.split('.').first.gsub(%r{^\w+://}, '')
  @urls = @urls.map { |url| url =~ %r{://} ? url : "http://#{url}" }
  @opts = opts
  @cache = Ubi.memorias.reduce({}) { |a, e| a.merge(e => opts[e]) }
  reduce_names
end

Public Instance Methods

araneas() click to toggle source
# File lib/ubi/thema.rb, line 22
def araneas
  @araneas ||= urls.map { |u| Aranea.new(self, u) }
end
reduce_names() click to toggle source
# File lib/ubi/thema.rb, line 26
def reduce_names
  return unless name
  @ascii = name.mb_chars.downcase
  @downcase = name.mb_chars.downcase
  @clean = @downcase.gsub(/\W/, ' ')
end
spec() click to toggle source
# File lib/ubi/thema.rb, line 41
def spec
  puts self
  Ubi.memorias.each do |memoria|
    d = send(memoria.plural)
    puts Paint["#{memoria.name} (#{d.size})", :black]
    puts d
  end
end
to_s() click to toggle source
# File lib/ubi/thema.rb, line 62
def to_s
  name
end
try_datum(a) click to toggle source
# File lib/ubi/thema.rb, line 50
def try_datum(a)
  Ubi.memorias.each do |m|
    print Paint["Trying to find #{m} in page ", :green]
    matches = m.parse(a)
    puts Paint[matches.size, :black]
    next unless matches && !matches.empty?
    matches.each do |match|
      send(m.plural) << match unless send(m.plural).include?(match)
    end
  end
end