Class: E621::Artist
- Inherits:
-
Object
- Object
- E621::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.
42 43 44 |
# File 'lib/rubyhexagon/artist.rb', line 42 def initialize(artist) @name = artist end |
Instance Attribute Details
#alternative_names ⇒ Array<String> (readonly)
Returns alternative names for artist.
30 31 32 |
# File 'lib/rubyhexagon/artist.rb', line 30 def alternative_names @alternative_names end |
#id ⇒ Integer (readonly)
Returns id of artist.
24 25 26 |
# File 'lib/rubyhexagon/artist.rb', line 24 def id @id end |
#name ⇒ String (readonly)
Returns name of artist.
27 28 29 |
# File 'lib/rubyhexagon/artist.rb', line 27 def name @name end |
#urls ⇒ Array<URI> (readonly)
Returns links to find artist.
33 34 35 |
# File 'lib/rubyhexagon/artist.rb', line 33 def urls @urls end |
Instance Method Details
#==(other) ⇒ TrueClass, FalseClass
Comparison method for artists
73 74 75 76 77 78 79 80 |
# File 'lib/rubyhexagon/artist.rb', line 73 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
88 89 90 |
# File 'lib/rubyhexagon/artist.rb', line 88 def active? @active end |
#show ⇒ Artist
Returns a filled Artist object
62 63 64 65 66 |
# File 'lib/rubyhexagon/artist.rb', line 62 def show artist = Artist.new(@name) artist.show! artist end |
#show! ⇒ Object
Fills this object with additional artist data
49 50 51 52 53 54 55 |
# File 'lib/rubyhexagon/artist.rb', line 49 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 |