Class: Ubi::Thema
- Inherits:
-
Object
- Object
- Ubi::Thema
- Includes:
- ActiveModel::AttributeMethods, ActiveModel::Dirty, ActiveModel::Serialization
- Defined in:
- lib/ubi/thema.rb
Overview
Thema -> subject, matter, case
Instance Attribute Summary collapse
-
#ascii ⇒ Object
Returns the value of attribute ascii.
-
#clean ⇒ Object
Returns the value of attribute clean.
-
#name ⇒ Object
Returns the value of attribute name.
-
#opts ⇒ Object
Returns the value of attribute opts.
-
#urls ⇒ Object
Returns the value of attribute urls.
Instance Method Summary collapse
- #[](arg) ⇒ Object
- #araneas ⇒ Object
-
#initialize(name, urls = [], opts = {}) ⇒ Thema
constructor
A new instance of Thema.
- #reduce_names ⇒ Object
- #spec ⇒ Object
- #to_s ⇒ Object
- #try_consultor(a) ⇒ Object
Constructor Details
#initialize(name, urls = [], opts = {}) ⇒ Thema
Returns a new instance of Thema.
12 13 14 15 16 17 18 |
# File 'lib/ubi/thema.rb', line 12 def initialize(name, urls = [], opts = {}) @name = name @urls = urls @opts = opts @cache = Ubi.memorias.reduce({}) { |a, e| a.merge(e => opts[e]) } reduce_names end |
Instance Attribute Details
#ascii ⇒ Object
Returns the value of attribute ascii.
10 11 12 |
# File 'lib/ubi/thema.rb', line 10 def ascii @ascii end |
#clean ⇒ Object
Returns the value of attribute clean.
10 11 12 |
# File 'lib/ubi/thema.rb', line 10 def clean @clean end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/ubi/thema.rb', line 10 def name @name end |
#opts ⇒ Object
Returns the value of attribute opts.
10 11 12 |
# File 'lib/ubi/thema.rb', line 10 def opts @opts end |
#urls ⇒ Object
Returns the value of attribute urls.
10 11 12 |
# File 'lib/ubi/thema.rb', line 10 def urls @urls end |
Instance Method Details
#[](arg) ⇒ Object
37 38 39 |
# File 'lib/ubi/thema.rb', line 37 def [](arg) @cache[arg] end |
#araneas ⇒ Object
20 21 22 |
# File 'lib/ubi/thema.rb', line 20 def araneas @araneas ||= urls.map { |u| Aranea.new(self, u) } end |
#reduce_names ⇒ Object
24 25 26 27 28 |
# File 'lib/ubi/thema.rb', line 24 def reduce_names @ascii = name.mb_chars.downcase @downcase = name.mb_chars.downcase @clean = @downcase.gsub(/\W/, ' ') end |
#spec ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/ubi/thema.rb', line 41 def spec puts self Ubi.memorias.each do |memoria| print Paint[memoria.name, :black] puts self[memoria.key] end end |
#to_s ⇒ Object
58 59 60 |
# File 'lib/ubi/thema.rb', line 58 def to_s name end |
#try_consultor(a) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/ubi/thema.rb', line 49 def try_consultor(a) a = a.new(self) Ubi.memorias.each do |m| puts Paint["Trying to find #{m} in #{a.class}", :green] @cache[m] = matches = m.parse(a.datum) puts matches if matches && !matches.empty? end end |