Class: Ogo::Opengraph

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(src, options = {}) ⇒ Opengraph

Returns a new instance of Opengraph.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ogo/opengraph.rb', line 8

def initialize(src, options = {})
  @src = src
  @body = nil
  @images = []
   = {}
  @charset = 'utf-8'
  @error = nil

  @_fallback = options[:fallback] || true
  @_options = options
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/ogo/opengraph.rb', line 4

def body
  @body
end

#charsetObject

Returns the value of attribute charset.



4
5
6
# File 'lib/ogo/opengraph.rb', line 4

def charset
  @charset
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/ogo/opengraph.rb', line 4

def description
  @description
end

#errorObject

Returns the value of attribute error.



4
5
6
# File 'lib/ogo/opengraph.rb', line 4

def error
  @error
end

#imagesObject

Returns the value of attribute images.



4
5
6
# File 'lib/ogo/opengraph.rb', line 4

def images
  @images
end

#metadataObject

Returns the value of attribute metadata.



4
5
6
# File 'lib/ogo/opengraph.rb', line 4

def 
  
end

#original_imagesObject

Returns the value of attribute original_images.



4
5
6
# File 'lib/ogo/opengraph.rb', line 4

def original_images
  @original_images
end

#responseObject

Returns the value of attribute response.



4
5
6
# File 'lib/ogo/opengraph.rb', line 4

def response
  @response
end

#srcObject

Returns the value of attribute src.



4
5
6
# File 'lib/ogo/opengraph.rb', line 4

def src
  @src
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/ogo/opengraph.rb', line 4

def title
  @title
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/ogo/opengraph.rb', line 4

def type
  @type
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/ogo/opengraph.rb', line 4

def url
  @url
end

Instance Method Details

#inspectObject



32
33
34
35
36
# File 'lib/ogo/opengraph.rb', line 32

def inspect
  str = "<Ogo::Opengraph:0x00#{'%x' % (self.object_id << 1)}\nurl=\"#{url}\",\nmetadata=#{metadata},\n"
  str << "images=#{images},\ntype=\"#{type}\",\ntitle=\"#{title}\">"
  str
end

#parseObject



20
21
22
23
24
25
# File 'lib/ogo/opengraph.rb', line 20

def parse
  parse_opengraph(@_options)
  load_fallback if @_fallback
  check_images_path
  self
end

#parse!Object



27
28
29
30
# File 'lib/ogo/opengraph.rb', line 27

def parse!
  parse
  error ? raise(error) : self
end

#to_sObject



38
39
40
# File 'lib/ogo/opengraph.rb', line 38

def to_s
  inspect
end