Class: QuickMug::Album
- Inherits:
-
Object
- Object
- QuickMug::Album
- Defined in:
- lib/quickmug/album.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
Instance Method Summary collapse
- #apiHash ⇒ Object
- #images ⇒ Object
- #info ⇒ Object
-
#initialize(id, key) ⇒ Album
constructor
A new instance of Album.
- #selected? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(id, key) ⇒ Album
5 6 7 8 |
# File 'lib/quickmug/album.rb', line 5 def initialize(id, key) @id = id @key = key end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/quickmug/album.rb', line 3 def id @id end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
3 4 5 |
# File 'lib/quickmug/album.rb', line 3 def key @key end |
Class Method Details
.all ⇒ Object
42 43 44 45 46 |
# File 'lib/quickmug/album.rb', line 42 def self.all @@albums ||= QuickMug.client.albums.get.map do |data| Album.fromApi(data) end end |
.fromApi(data) ⇒ Object
33 34 35 |
# File 'lib/quickmug/album.rb', line 33 def self.fromApi(data) Album.new(data['id'], data['Key']) end |
.fromArgs(args) ⇒ Object
37 38 39 40 |
# File 'lib/quickmug/album.rb', line 37 def self.fromArgs(args) raise ArgumentError.new('You must specify an image ID and KEY') if args.size < 2 Album.new(args[0],args[1]) end |
.selected ⇒ Object
48 49 50 |
# File 'lib/quickmug/album.rb', line 48 def self.selected @@selected ||= self.all.find(&:selected?) end |
Instance Method Details
#apiHash ⇒ Object
10 11 12 |
# File 'lib/quickmug/album.rb', line 10 def apiHash {:AlbumID => @id, :AlbumKey => @key} end |
#images ⇒ Object
18 19 20 21 22 |
# File 'lib/quickmug/album.rb', line 18 def images @images ||= QuickMug.client.images.get(apiHash)['Images'].map do |data| Image.fromApi(data) end end |
#info ⇒ Object
14 15 16 |
# File 'lib/quickmug/album.rb', line 14 def info @info ||= QuickMug.client.albums.getInfo(apiHash) end |
#selected? ⇒ Boolean
24 25 26 |
# File 'lib/quickmug/album.rb', line 24 def selected? self.id == QuickMug.config['album'] end |
#to_s ⇒ Object
28 29 30 31 |
# File 'lib/quickmug/album.rb', line 28 def to_s selected = selected? ? '*' : ' ' " #{selected} #{info['Title']} id:#@id key:#@key" end |