Class: Pollex::Language
- Inherits:
-
PollexObject
- Object
- PollexObject
- Pollex::Language
- Extended by:
- PollexClass
- Defined in:
- lib/pollex/language.rb
Overview
A Polynesian language with entries in Pollex.
Instance Attribute Summary collapse
-
#code ⇒ String
The Language’s abbreviated code.
-
#count ⇒ Integer
Number of Entries belonging to this Language.
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
Attributes included from PollexClass
Class Method Summary collapse
-
.all ⇒ Array<Language>
Returns all Languages in Pollex.
-
.count ⇒ Integer
Counts the number of Languages within Pollex.
-
.find(name) ⇒ Array<Language>
Looks up all Languages matching a given name.
Instance Method Summary collapse
-
#entries ⇒ Array<Entry>
Returns all Entries belonging to this Language.
Methods included from PollexClass
Methods inherited from PollexObject
Constructor Details
This class inherits a constructor from Pollex::PollexObject
Instance Attribute Details
#code ⇒ String
Returns the Language’s abbreviated code.
25 26 27 |
# File 'lib/pollex/language.rb', line 25 def code @code ||= self.all.find {|l| l.name == @name}.code end |
#count ⇒ Integer
Returns number of Entries belonging to this Language.
30 31 32 33 34 |
# File 'lib/pollex/language.rb', line 30 def count @count ||= Scraper.instance.get(@path, [ [:count, "p[@class='count']/text()", lambda {|x| x.split(' ').first}] ])[:count].to_i end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/pollex/language.rb', line 6 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/pollex/language.rb', line 6 def path @path end |
Class Method Details
.all ⇒ Array<Language>
Returns all Languages in Pollex.
38 39 40 41 42 43 44 45 |
# File 'lib/pollex/language.rb', line 38 def self.all @languages ||= Scraper.instance.get_all(Language, "/language/", [ [:name, 'td[2]/a/text()'], [:path, 'td[1]/a/@href'], [:code, 'td[1]/a/text()'], [:count, 'td[3]/text()'] ]) end |
.count ⇒ Integer
Counts the number of Languages within Pollex
49 50 51 |
# File 'lib/pollex/language.rb', line 49 def self.count self.all.count end |
Instance Method Details
#entries ⇒ Array<Entry>
Returns all Entries belonging to this Language
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pollex/language.rb', line 12 def entries @entries ||= Scraper.instance.get_all(Entry, @path, [ [:reflex, 'td[2]/text()'], [:description, 'td[3]/text()'], [:language_name, nil, lambda {|x| @name}], [:language_path, nil, lambda {|x| @path}], [:source_code, 'td[4]/a/text()'], [:source_path, 'td[4]/a/@href'], [:flag, "td[3]/span[@class='flag']/text()"] ]) end |