Class: Philologic::Client::Frequency

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

Overview

Philologic frequency table.

Extends Philologic::Client::Response

Instance Attribute Summary collapse

Attributes inherited from Response

#client

Instance Method Summary collapse

Methods inherited from Response

#[], #each, #keys

Constructor Details

#initialize(document, client = nil) ⇒ Frequency

Initialize Philologic::Client::Frequency object.

Params:

document

Nokogiri document

client

(optional) Philologic::Client object or nil



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/philologic-client/frequency.rb', line 34

def initialize(document, client = nil)
  super

  header = @doc.css('table.philologic_table > tr.freq_header_row').first
  unless header.nil?
    @label_header = header.css('th.freq_label_header').first.text
    @value_header = header.css('th.freq_value_header').first.text
  end

  @results = @doc.css('tr.freq_row').collect { |tr| Philologic::Client::FrequencyRow.new(tr) }
end

Instance Attribute Details

#label_headerObject (readonly)

Get label header or nil



15
16
17
# File 'lib/philologic-client/frequency.rb', line 15

def label_header
  @label_header
end

#resultsObject (readonly)

Get Array of Philologic::Client::FrequencyRow objects



20
21
22
# File 'lib/philologic-client/frequency.rb', line 20

def results
  @results
end

#value_headerObject (readonly)

Get value header or nil



25
26
27
# File 'lib/philologic-client/frequency.rb', line 25

def value_header
  @value_header
end

Instance Method Details

#results?Boolean

Does this frequency table contain results?

Returns:

  • (Boolean)


49
50
51
# File 'lib/philologic-client/frequency.rb', line 49

def results?
  @results.size > 0 ? true : false
end