Class: Rubyhexagon::Artist
- Inherits:
-
Object
- Object
- Rubyhexagon::Artist
- Defined in:
- lib/rubyhexagon/artist.rb
Overview
Class to hold information about an artist on e621
Instance Attribute Summary collapse
-
#alternative_names ⇒ Array<String>
readonly
Alternative names for artist.
-
#id ⇒ Integer
readonly
Id of artist.
-
#name ⇒ String
readonly
Name of artist.
-
#urls ⇒ Array<URI>
readonly
Links to find artist.
Instance Method Summary collapse
-
#==(other) ⇒ TrueClass, FalseClass
Comparison method for artists.
-
#active? ⇒ TrueClass, FalseClass
Check if this artist is active.
-
#initialize(artist) ⇒ Object
constructor
Initializer for Artist.
-
#show ⇒ Artist
Returns a filled Artist object.
-
#show! ⇒ Object
Fills this object with additional artist data.
Constructor Details
#initialize(artist) ⇒ Object
Initializer for Artist.
44 45 46 |
# File 'lib/rubyhexagon/artist.rb', line 44 def initialize(artist) @name = artist end |
Instance Attribute Details
#alternative_names ⇒ Array<String> (readonly)
Returns alternative names for artist.
32 33 34 |
# File 'lib/rubyhexagon/artist.rb', line 32 def alternative_names @alternative_names end |
#id ⇒ Integer (readonly)
Returns id of artist.
26 27 28 |
# File 'lib/rubyhexagon/artist.rb', line 26 def id @id end |
#name ⇒ String (readonly)
Returns name of artist.
29 30 31 |
# File 'lib/rubyhexagon/artist.rb', line 29 def name @name end |
#urls ⇒ Array<URI> (readonly)
Returns links to find artist.
35 36 37 |
# File 'lib/rubyhexagon/artist.rb', line 35 def urls @urls end |
Instance Method Details
#==(other) ⇒ TrueClass, FalseClass
Comparison method for artists
75 76 77 78 79 80 81 82 |
# File 'lib/rubyhexagon/artist.rb', line 75 def ==(other) return false unless other.is_a?(Artist) if @id && other.id @id == other.id && @name == other.name else @name == other.name end end |
#active? ⇒ TrueClass, FalseClass
Check if this artist is active
90 91 92 |
# File 'lib/rubyhexagon/artist.rb', line 90 def active? @active end |
#show ⇒ Artist
Returns a filled Artist object
64 65 66 67 68 |
# File 'lib/rubyhexagon/artist.rb', line 64 def show artist = Artist.new(@name) artist.show! artist end |
#show! ⇒ Object
Fills this object with additional artist data
51 52 53 54 55 56 57 |
# File 'lib/rubyhexagon/artist.rb', line 51 def show! artist = API.new.fetch('artist', 'index', name: @name).first @id = artist[:id].to_i @alternative_names = artist[:other_names].split(/,\s+/) @urls = artist[:urls].map { |u| URI(u) } @active = artist[:is_active] end |