Class: Pollex::Level
- Inherits:
-
PollexObject
- Object
- PollexObject
- Pollex::Level
- Extended by:
- PollexClass
- Defined in:
- lib/pollex/level.rb
Overview
A level to which protoforms are reconstructed within Pollex.
Instance Attribute Summary collapse
-
#count ⇒ Integer
Number of Reconstructions at this Level.
-
#path ⇒ Object
Returns the value of attribute path.
-
#subgroup ⇒ Object
The full name of this Level.
-
#token ⇒ Object
Returns the value of attribute token.
Attributes included from PollexClass
Class Method Summary collapse
-
.all ⇒ Array<Level>
Returns all Levels in Pollex.
-
.count ⇒ Integer
Counts the number of Levels within Pollex.
Instance Method Summary collapse
-
#reconstructions ⇒ Array<Reconstruction>
Returns all Reconstructions at this Level.
Methods included from PollexClass
Methods inherited from PollexObject
Constructor Details
This class inherits a constructor from Pollex::PollexObject
Instance Attribute Details
#count ⇒ Integer
Returns number of Reconstructions at this Level.
28 29 30 31 32 |
# File 'lib/pollex/level.rb', line 28 def count @count ||= Scraper.instance.get(@path, [ [:count, "p[@class='count']/text()", lambda {|x| x.split(' ').first}] ])[:count] end |
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/pollex/level.rb', line 6 def path @path end |
#subgroup ⇒ Object
Returns the full name of this Level.
21 22 23 24 25 |
# File 'lib/pollex/level.rb', line 21 def subgroup @subgroup ||= Scraper.instance.get(@path, [ [:subgroup, 'h1/text()', lambda {|x| x.split(' - ')[1]}] ])[:subgroup] end |
#token ⇒ Object
Returns the value of attribute token.
6 7 8 |
# File 'lib/pollex/level.rb', line 6 def token @token end |
Class Method Details
.all ⇒ Array<Level>
Returns all Levels in Pollex.
36 37 38 39 40 41 42 43 |
# File 'lib/pollex/level.rb', line 36 def self.all @levels ||= Scraper.instance.get_all(Source, "/level/", [ [:token, 'td[1]/a/text()'], [:subgroup, 'td[2]/a/text()'], [:path, 'td[2]/a/@href'], [:count, 'td[3]/a/text()'], ]) end |
.count ⇒ Integer
Counts the number of Levels within Pollex
47 48 49 |
# File 'lib/pollex/level.rb', line 47 def self.count self.all.count end |
Instance Method Details
#reconstructions ⇒ Array<Reconstruction>
Returns all Reconstructions at this Level
12 13 14 15 16 17 18 |
# File 'lib/pollex/level.rb', line 12 def reconstructions @reconstructions ||= Scraper.instance.get_all(Reconstruction, @path, [ [:path, 'td[1]/a/@href'], [:protoform, 'td[1]/a/text()'], [:description, 'td[2]/text()'] ]) end |