Class: Rb::Lomo::Photo
- Inherits:
-
Object
- Object
- Rb::Lomo::Photo
- Defined in:
- lib/rb-lomo/photo.rb
Instance Attribute Summary collapse
-
#camera ⇒ Object
readonly
The camera attributes of the Photo.
-
#description ⇒ Object
readonly
The description attribute of the Photo.
-
#film ⇒ Object
readonly
The film attribute of the Photo.
-
#id ⇒ Object
readonly
The ID attribute of the Photo.
-
#title ⇒ Object
readonly
The title attribute of the Photo.
-
#url ⇒ Object
readonly
The URL attribute of the Photo.
-
#user ⇒ Object
readonly
The user attribute of the Photo.
Instance Method Summary collapse
-
#initialize(json) ⇒ Photo
constructor
Expects a JSON object.
- #large_asset_url ⇒ Object
- #location ⇒ Object
- #size ⇒ Object
- #small_asset_url ⇒ Object
Constructor Details
#initialize(json) ⇒ Photo
Expects a JSON object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rb-lomo/photo.rb', line 37 def initialize json @json = json @id = @json['id'] @title = @json['title'] @description= @json['description'] @url = @json['url'] @user = User.new @json['user'] if @json['camera'] @camera = Camera.new @json['camera'] end if @json['film'] @film = Film.new @json['film'] end if @json['longitude'] && @json['latitude'] @longitude = @json['location']['longitude'] @latitude = @json['location']['latitude'] end end |
Instance Attribute Details
#camera ⇒ Object (readonly)
The camera attributes of the Photo
23 24 25 |
# File 'lib/rb-lomo/photo.rb', line 23 def camera @camera end |
#description ⇒ Object (readonly)
The description attribute of the Photo
14 15 16 |
# File 'lib/rb-lomo/photo.rb', line 14 def description @description end |
#film ⇒ Object (readonly)
The film attribute of the Photo
28 29 30 |
# File 'lib/rb-lomo/photo.rb', line 28 def film @film end |
#id ⇒ Object (readonly)
The ID attribute of the Photo
6 7 8 |
# File 'lib/rb-lomo/photo.rb', line 6 def id @id end |
#title ⇒ Object (readonly)
The title attribute of the Photo
10 11 12 |
# File 'lib/rb-lomo/photo.rb', line 10 def title @title end |
#url ⇒ Object (readonly)
The URL attribute of the Photo
18 19 20 |
# File 'lib/rb-lomo/photo.rb', line 18 def url @url end |
#user ⇒ Object (readonly)
The user attribute of the Photo
33 34 35 |
# File 'lib/rb-lomo/photo.rb', line 33 def user @user end |
Instance Method Details
#large_asset_url ⇒ Object
75 76 77 |
# File 'lib/rb-lomo/photo.rb', line 75 def large_asset_url @json['assets']['large']['url'] end |
#location ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rb-lomo/photo.rb', line 59 def location if @longitude && @latitude { longitude: @longitude, latitude: @latitude } else 'Location unknown' end end |
#size ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rb-lomo/photo.rb', line 79 def size { small: { width: @json['assets']['small']['width'], height: @json['assets']['small']['height'] }, large: { width: @json['assets']['large']['width'], height: @json['assets']['large']['height'] } } end |
#small_asset_url ⇒ Object
71 72 73 |
# File 'lib/rb-lomo/photo.rb', line 71 def small_asset_url @json['assets']['small']['url'] end |