Class: Philologic::Client::FrequencyRow

Inherits:
Object
  • Object
show all
Defined in:
lib/philologic-client/frequency_row.rb

Overview

Philologic frequency table row.

Usage

# <tr class='freq_row'>
#   <td class='freq_label'>
#     <a href='./?q=lion&title=A+Midsummer+Night%27s+Dream'>
#       A Midsummer Night's Dream
#     </a>
#   </td>
#   <td class='freq_value'>
#     30
#   </td>
# </tr>

r = Philologic::Client::FrequencyRow.new(html)
r.label # "A Midsummer Night's Dream"
r.link  # './?q=lion&title=A+Midsummer+Night%27s+Dream'
r.value # "0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document) ⇒ FrequencyRow

Initialize Philologic::Client::FrequencyRow object.

Params:

document

Nokogiri document



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/philologic-client/frequency_row.rb', line 49

def initialize(document)
  @label = @link = @value = nil

  unless document.css('td.freq_label').first.nil?
    @label = document.css('td.freq_label').first.text
  end
  unless document.css('a').first.nil?
    @link = document.css('a').first.attributes['href'].value
  end
  unless document.css('td.freq_value').first.nil?
    @value = document.css('td.freq_value').first.text
  end
end

Instance Attribute Details

#labelObject (readonly)

Get label or nil



31
32
33
# File 'lib/philologic-client/frequency_row.rb', line 31

def label
  @label
end

Get link or nil



36
37
38
# File 'lib/philologic-client/frequency_row.rb', line 36

def link
  @link
end

#valueObject (readonly)

Get value or nil



41
42
43
# File 'lib/philologic-client/frequency_row.rb', line 41

def value
  @value
end