Class: Textract::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/textract.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, selectors) ⇒ Client

Returns a new instance of Client.



67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/textract.rb', line 67

def initialize(url, selectors)
  @url = url
  @html = HTTParty.get url
  @tags = Textract.get_og_tags(@html)
  if @tags.nil? or @tags.description.nil?
    # use readability method
    @text = Textract.get_text_from_description(@html, nil, selectors)
    @title = Textract.get_page_title(@html)
  else
    @text = Textract.get_text_from_description(@html, @tags.description, selectors)
    @title = @tags.title
  end
end

Instance Attribute Details

#htmlObject (readonly)

Returns the value of attribute html.



61
62
63
# File 'lib/textract.rb', line 61

def html
  @html
end

#tagsObject (readonly)

Returns the value of attribute tags.



63
64
65
# File 'lib/textract.rb', line 63

def tags
  @tags
end

#textObject (readonly)

Returns the value of attribute text.



65
66
67
# File 'lib/textract.rb', line 65

def text
  @text
end

#titleObject (readonly)

Returns the value of attribute title.



64
65
66
# File 'lib/textract.rb', line 64

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



62
63
64
# File 'lib/textract.rb', line 62

def url
  @url
end