Class: Pollex::Reconstruction
- Inherits:
-
PollexObject
- Object
- PollexObject
- Pollex::Reconstruction
- Extended by:
- PollexClass
- Defined in:
- lib/pollex/reconstruction.rb
Overview
A reconstructed protoform in Pollex.
Instance Attribute Summary collapse
-
#description ⇒ String
The Reconstruction’s description.
-
#path ⇒ Object
Returns the value of attribute path.
-
#protoform ⇒ Object
Returns the value of attribute protoform.
-
#semantic_field ⇒ Object
Returns the value of attribute semantic_field.
Attributes included from PollexClass
Class Method Summary collapse
-
.all ⇒ Array<Reconstruction>
Returns all Reconstructions in Pollex.
-
.count ⇒ Integer
Counts the number of Reconstruction within Pollex.
-
.find(name) ⇒ Array<Reconstruction>
Looks up all Reconstructions matching a given name.
Instance Method Summary collapse
-
#count ⇒ Integer
Number of Entries belonging to this Reconstruction.
-
#entries ⇒ Array<Entry>
Returns all Entries belonging to this Reconstruction.
-
#level ⇒ Level
The Level corresponding to this Reconstruction.
-
#notes ⇒ String
The Reconstruction’s notes.
Methods included from PollexClass
Methods inherited from PollexObject
Constructor Details
This class inherits a constructor from Pollex::PollexObject
Instance Attribute Details
#description ⇒ String
Returns the Reconstruction’s description.
26 27 28 |
# File 'lib/pollex/reconstruction.rb', line 26 def description @description end |
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/pollex/reconstruction.rb', line 6 def path @path end |
#protoform ⇒ Object
Returns the value of attribute protoform.
6 7 8 |
# File 'lib/pollex/reconstruction.rb', line 6 def protoform @protoform end |
#semantic_field ⇒ Object
Returns the value of attribute semantic_field.
6 7 8 |
# File 'lib/pollex/reconstruction.rb', line 6 def semantic_field @semantic_field end |
Class Method Details
.all ⇒ Array<Reconstruction>
Returns all Reconstructions in Pollex.
60 61 62 63 64 65 66 |
# File 'lib/pollex/reconstruction.rb', line 60 def self.all @sources ||= Scraper.instance.get_all(Reconstruction, "/entry/", [ [:path, 'td[2]/a/@href'], [:protoform, 'td[2]/a/text()'], [:description, 'td[3]/text()'] ]) end |
.count ⇒ Integer
Counts the number of Reconstruction within Pollex
70 71 72 73 74 |
# File 'lib/pollex/reconstruction.rb', line 70 def self.count @count ||= Scraper.instance.get("/entry/", [ [:count, "p[@class='count']/text()", lambda {|x| x.split(' ').first}] ])[:count] end |
.find(name) ⇒ Array<Reconstruction>
Looks up all Reconstructions matching a given name.
79 80 81 82 83 84 85 |
# File 'lib/pollex/reconstruction.rb', line 79 def self.find(name) Scraper.instance.get_all(Reconstruction, "/search/?field=protoform&query=#{name}", [ [:path, 'td[2]/a/@href'], [:protoform, 'td[2]/a/text()'], [:description, 'td[3]/text()'] ]) end |
Instance Method Details
#count ⇒ Integer
Returns number of Entries belonging to this Reconstruction.
52 53 54 55 56 |
# File 'lib/pollex/reconstruction.rb', line 52 def count @count ||= Scraper.instance.get(@path, [ [:count, "p[@class='count']/text()", lambda {|x| x.split(' ').first}] ])[:count] end |
#entries ⇒ Array<Entry>
Returns all Entries belonging to this Reconstruction
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pollex/reconstruction.rb', line 11 def entries @entries ||= Scraper.instance.get_all(Entry, @path, [ [:reflex, 'td[2]/text()'], [:description, 'td[3]/text()'], [:language_name, 'td[1]/a/text()'], [:language_path, 'td[1]/a/@href'], [:source_code, 'td[4]/a/text()'], [:source_path, 'td[4]/a/@href'], [:reconstruction_name, nil, lambda {|x| @protoform}], [:reconstruction_path, nil, lambda {|x| @path}], [:flag, "td[3]/span[@class='flag']/text()"] ], 1) end |
#level ⇒ Level
Returns the Level corresponding to this Reconstruction.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pollex/reconstruction.rb', line 33 def level unless @level level_parts = Scraper.instance.get(@path, [ [:token, "table[1]/tr[2]/td/a/text()", lambda {|x| x.split(':')[0]}], [:path, "table[1]/tr[2]/td/a/@href"] ]) @level = Level.new(:token => level_parts[:token], :path => level_parts[:path]) end @level end |
#notes ⇒ String
Returns the Reconstruction’s notes.
45 46 47 48 49 |
# File 'lib/pollex/reconstruction.rb', line 45 def notes @notes ||= Scraper.instance.get(@path, [ [:notes, "table[1]/tr[3]/td/p/text()"] ])[:notes] end |