Class: Pollex::Level

Inherits:
PollexObject show all
Extended by:
PollexClass
Defined in:
lib/pollex/level.rb

Overview

A level to which protoforms are reconstructed within Pollex.

Instance Attribute Summary collapse

Attributes included from PollexClass

#inspectables

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PollexClass

attr_inspector

Methods inherited from PollexObject

#initialize, #inspect

Constructor Details

This class inherits a constructor from Pollex::PollexObject

Instance Attribute Details

#countInteger

Returns number of Reconstructions at this Level.

Returns:

  • (Integer)

    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

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/pollex/level.rb', line 6

def path
  @path
end

#subgroupObject

Returns the full name of this Level.

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

#tokenObject

Returns the value of attribute token.



6
7
8
# File 'lib/pollex/level.rb', line 6

def token
  @token
end

Class Method Details

.allArray<Level>

Returns all Levels in Pollex.

Returns:

  • (Array<Level>)

    array of 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

.countInteger

Counts the number of Levels within Pollex

Returns:

  • (Integer)

    number of Levels in Pollex



47
48
49
# File 'lib/pollex/level.rb', line 47

def self.count
  self.all.count
end

Instance Method Details

#reconstructionsArray<Reconstruction>

Returns all Reconstructions at this Level

Returns:



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