Class: PhishDotNetClient::Song

Inherits:
Object
  • Object
show all
Defined in:
lib/phish_dot_net_client/song.rb

Overview

This class represents a set from the ‘setlistdata’ field.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Song

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Song.

Parameters:

  • attrs (Hash<Symbol, Object>) (defaults to: {})

    the song attributes

Options Hash (attrs):

  • :title (String)

    the song title

  • :url (String)

    the song url

  • :slug (String)

    the song slug

  • :instance (Integer)

    the instance number of the song

  • :position_in_set (Integer)

    set position of the song

  • :position_in_show (Integer)

    show position of the song



56
57
58
59
60
61
62
63
64
# File 'lib/phish_dot_net_client/song.rb', line 56

def initialize(attrs={})
  @title = attrs[:title]
  @url = attrs[:url]
  @slug = attrs[:slug]
  @instance = attrs[:instance]
  @position_in_set = attrs[:position_in_set]
  @position_in_show = attrs[:position_in_show]
  @footnotes = []
end

Instance Attribute Details

#footnotesObject (readonly)

Returns the value of attribute footnotes.



37
38
39
# File 'lib/phish_dot_net_client/song.rb', line 37

def footnotes
  @footnotes
end

#instanceObject (readonly)

Returns the value of attribute instance.



24
25
26
# File 'lib/phish_dot_net_client/song.rb', line 24

def instance
  @instance
end

#position_in_setObject (readonly)

Returns the value of attribute position_in_set.



28
29
30
# File 'lib/phish_dot_net_client/song.rb', line 28

def position_in_set
  @position_in_set
end

#position_in_showObject (readonly)

Returns the value of attribute position_in_show.



32
33
34
# File 'lib/phish_dot_net_client/song.rb', line 32

def position_in_show
  @position_in_show
end

#post_transitionSongTransition

Returns the transition to the next song.

Returns:



45
46
47
# File 'lib/phish_dot_net_client/song.rb', line 45

def post_transition
  @post_transition
end

#pre_transitionSongTransition

Returns the transition to the previous song.

Returns:



41
42
43
# File 'lib/phish_dot_net_client/song.rb', line 41

def pre_transition
  @pre_transition
end

#slugObject (readonly)

Returns the value of attribute slug.



19
20
21
# File 'lib/phish_dot_net_client/song.rb', line 19

def slug
  @slug
end

#titleObject (readonly)

Returns the value of attribute title.



10
11
12
# File 'lib/phish_dot_net_client/song.rb', line 10

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



14
15
16
# File 'lib/phish_dot_net_client/song.rb', line 14

def url
  @url
end

Instance Method Details

#to_sString

Returns the song along with pre and post transitions.

Returns:

  • (String)

    the song along with pre and post transitions



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/phish_dot_net_client/song.rb', line 67

def to_s
  s = StringIO.new

  if pre_transition
    s.print "#{pre_transition.from_song.title}(#{pre_transition.from_song.instance})..."
  else
    s.print "x..."
  end

  s.print "#{@title}(#{@instance})"

  if post_transition
    s.puts "...#{post_transition.to_song.title}(#{post_transition.to_song.instance})"
  else
    s.puts "...x"
  end

  s.puts
  return s.string
end