Class: Pollex::Reconstruction

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

Overview

A reconstructed protoform in 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

#descriptionString

Returns the Reconstruction’s description.

Returns:

  • (String)

    the Reconstruction’s description



26
27
28
# File 'lib/pollex/reconstruction.rb', line 26

def description
  @description
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

#protoformObject

Returns the value of attribute protoform.



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

def protoform
  @protoform
end

#semantic_fieldObject

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

.allArray<Reconstruction>

Returns all Reconstructions in Pollex.

Returns:



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

.countInteger

Counts the number of Reconstruction within Pollex

Returns:

  • (Integer)

    number of Reconstruction in 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.

Parameters:

  • name (String)

    term to search for

Returns:

  • (Array<Reconstruction>)

    array of Reconstructions matching the search term



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

#countInteger

Returns number of Entries belonging to this Reconstruction.

Returns:

  • (Integer)

    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

#entriesArray<Entry>

Returns all Entries belonging to this Reconstruction

Returns:

  • (Array<Entry>)

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

#levelLevel

Returns the Level corresponding to this Reconstruction.

Returns:

  • (Level)

    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

#notesString

Returns the Reconstruction’s notes.

Returns:

  • (String)

    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