Class: WikipediaWrapper::Image

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, width, height, data) ⇒ Image

Returns a new instance of Image.



53
54
55
56
57
58
59
60
61
# File 'lib/wikipedia_wrapper/image.rb', line 53

def initialize(url, width, height, data)

  @url = url
  @name = data[:name] || ''
  @mime = data[:mime] || ''
  @height = data[:height] || 0
  @width = data[:width] || 0

end

Instance Attribute Details

#heightObject (readonly)

makes attributes readable



51
52
53
# File 'lib/wikipedia_wrapper/image.rb', line 51

def height
  @height
end

#mimeObject (readonly)

makes attributes readable



51
52
53
# File 'lib/wikipedia_wrapper/image.rb', line 51

def mime
  @mime
end

#nameObject (readonly)

makes attributes readable



51
52
53
# File 'lib/wikipedia_wrapper/image.rb', line 51

def name
  @name
end

#urlObject (readonly)

makes attributes readable



51
52
53
# File 'lib/wikipedia_wrapper/image.rb', line 51

def url
  @url
end

#widthObject (readonly)

makes attributes readable



51
52
53
# File 'lib/wikipedia_wrapper/image.rb', line 51

def width
  @width
end

Instance Method Details

#to_sObject



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

def to_s
  "Image: #{@name} (#{@url})"
end