Class: RailsMug::Model::Album

Inherits:
Record
  • Object
show all
Defined in:
lib/RailsMug/model/album.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Record

#initialize

Constructor Details

This class inherits a constructor from RailsMug::Record

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.


58
59
60
# File 'lib/RailsMug/model/album.rb', line 58

def access_token
  @access_token
end

#backprintingObject (readonly)

The text to be printed on the back of prints purchased from this album


15
16
17
# File 'lib/RailsMug/model/album.rb', line 15

def backprinting
  @backprinting
end

#boutique_packagingObject (readonly)

Enable boutique packaging for orders from this album


17
18
19
# File 'lib/RailsMug/model/album.rb', line 17

def boutique_packaging
  @boutique_packaging
end

#can_rankObject (readonly)

Allow images from this album to be ranked using PhotoRank


19
20
21
# File 'lib/RailsMug/model/album.rb', line 19

def can_rank
  @can_rank
end

#categoryObject (readonly)

The category that this album belongs to


9
10
11
# File 'lib/RailsMug/model/album.rb', line 9

def category
  @category
end

#cleanObject (readonly)

Hide the Description and LastUpdated for this album on the homepage and category pages


21
22
23
# File 'lib/RailsMug/model/album.rb', line 21

def clean
  @clean
end

#color_correctionObject (readonly)

The color correction setting for this album (0 - No, 1 - Yes, 2 - Inherit)


23
24
25
# File 'lib/RailsMug/model/album.rb', line 23

def color_correction
  @color_correction
end

#commentsObject (readonly)

Allow visitors to leave comments on this album


25
26
27
# File 'lib/RailsMug/model/album.rb', line 25

def comments
  @comments
end

#communityObject (readonly)

The community that this album belongs to.


27
28
29
# File 'lib/RailsMug/model/album.rb', line 27

def community
  @community
end

#descriptionObject (readonly)

The description for this album


29
30
31
# File 'lib/RailsMug/model/album.rb', line 29

def description
  @description
end

#exifObject (readonly)

Allow EXIF data to be viewed for images from this album


31
32
33
# File 'lib/RailsMug/model/album.rb', line 31

def exif
  @exif
end

#externalObject (readonly)

Allow images from this album to be linked externally outside SmugMug


33
34
35
# File 'lib/RailsMug/model/album.rb', line 33

def external
  @external
end

#family_editObject (readonly)

Allow family to edit the captions and keywords of the images in this album


35
36
37
# File 'lib/RailsMug/model/album.rb', line 35

def family_edit
  @family_edit
end

#filenamesObject (readonly)

Show filename for images uploaded with no caption to this album


37
38
39
# File 'lib/RailsMug/model/album.rb', line 37

def filenames
  @filenames
end

#friend_editObject (readonly)

Allow friends to edit the captions and keywords of the images in this album


39
40
41
# File 'lib/RailsMug/model/album.rb', line 39

def friend_edit
  @friend_edit
end

#geographyObject (readonly)

Enable mapping features for this album


41
42
43
# File 'lib/RailsMug/model/album.rb', line 41

def geography
  @geography
end

#guest_upload_urlObject (readonly)

The URL to allow guests to upload to this gallery


43
44
45
# File 'lib/RailsMug/model/album.rb', line 43

def guest_upload_url
  @guest_upload_url
end

#headerObject (readonly)

Default this album to the standard SmugMug appearance. (false - Custom, true - SmugMug)


45
46
47
# File 'lib/RailsMug/model/album.rb', line 45

def header
  @header
end

#hide_ownerObject (readonly)

Hide the owner of this album.


47
48
49
# File 'lib/RailsMug/model/album.rb', line 47

def hide_owner
  @hide_owner
end

#highlightObject (readonly)

The highlight image for this album Key, Type


49
50
51
# File 'lib/RailsMug/model/album.rb', line 49

def highlight
  @highlight
end

#idObject (readonly)

The Id for this album


5
6
7
# File 'lib/RailsMug/model/album.rb', line 5

def id
  @id
end

#image_countObject (readonly)

The number of images in this album


51
52
53
# File 'lib/RailsMug/model/album.rb', line 51

def image_count
  @image_count
end

#imagesObject

Returns the value of attribute images.


57
58
59
# File 'lib/RailsMug/model/album.rb', line 57

def images
  @images
end

#keyObject (readonly)

The key for this album


7
8
9
# File 'lib/RailsMug/model/album.rb', line 7

def key
  @key
end

#keywordsObject (readonly)

The meta keyword string for this album


53
54
55
# File 'lib/RailsMug/model/album.rb', line 53

def keywords
  @keywords
end

#sub_categoryObject (readonly)

The sub category that this album belongs to


11
12
13
# File 'lib/RailsMug/model/album.rb', line 11

def sub_category
  @sub_category
end

#titleObject (readonly)

The title for this album


13
14
15
# File 'lib/RailsMug/model/album.rb', line 13

def title
  @title
end

#urlObject (readonly)

The URL for this album


55
56
57
# File 'lib/RailsMug/model/album.rb', line 55

def url
  @url
end

Instance Method Details

#add_image(image) ⇒ Object

Add image to album

Author:

  • David Slone


97
98
99
100
# File 'lib/RailsMug/model/album.rb', line 97

def add_image image
	self.images = [] if self.images.nil?
	self.images << image
end

#get_photosObject

Retrieve a list of images for an album

Parameters:

Raises:

Author:

  • David Slone


78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/RailsMug/model/album.rb', line 78

def get_photos
	response = self.access_token.get("/api/json/1.3.0/?method=smugmug.images.get&AlbumID=#{self.id}&AlbumKey=#{self.key}")
	json_response = JSON.parse(response.body)

	raise RailsMug::AlbumError, "SmugMug images.get Error: #{json_response['code']} - #{json_response['message']}" if json_response['stat'] == "fail"

	json_response['Album']['Images'].each do |img|
		img = RailsMug::Model::Image.new(
			:id => img['id'],
			:key => img['Key']
		)
		img.get_photo_info @access_token
		self.add_image img
	end
end

#to_jsonObject

Display Album in JSON format

Author:

  • David Slone


63
64
65
66
67
68
69
70
71
72
# File 'lib/RailsMug/model/album.rb', line 63

def to_json
	ret = {
		:id => self.id,
		:key => self.key,
		:category => self.category,
		:sub_category => self.sub_category,
		:title => self.title,
		:images => self.images
	}
end