Class: Widgetify::Base

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}, *args) ⇒ Base

Returns a new instance of Base.



13
14
15
16
17
18
19
20
# File 'lib/widgetify.rb', line 13

def initialize(url, options = {}, *args)
  @html_doc = Nokogiri::HTML(open(url))
  @parse_result = { }
  @options = options
  @options[:url] = url
  parse_all if args.length == 0
  args.each{ |arg| send(arg.to_sym)} if args.length > 0
end

Instance Attribute Details

#parse_resultObject (readonly)

Returns the value of attribute parse_result.



11
12
13
# File 'lib/widgetify.rb', line 11

def parse_result
  @parse_result
end

Instance Method Details

#parse_allObject



34
35
36
37
38
# File 'lib/widgetify.rb', line 34

def parse_all
  parse_open_graph
  parse_oembed
  parse_html
end

#parse_htmlObject



30
31
32
# File 'lib/widgetify.rb', line 30

def parse_html
  @parse_result['html'] = Widgetify::HTMLParser.new(@html_doc)
end

#parse_oembedObject



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

def parse_oembed
  @parse_result['oembed'] = Widgetify::OembedParser.new(@html_doc, @options)
end

#parse_open_graphObject



22
23
24
# File 'lib/widgetify.rb', line 22

def parse_open_graph
  @parse_result['open_graph'] = Widgetify::OpenGraphParser.new(@html_doc)
end