Class: Ipodcastly::Server::Episode

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/ipodcastly/server/episode.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, podcast_id, title, position, duration = 0) ⇒ Episode

Returns a new instance of Episode.



10
11
12
13
14
15
16
# File 'lib/ipodcastly/server/episode.rb', line 10

def initialize(id, podcast_id, title, position, duration = 0)
  @id = id
  @podcast_id = podcast_id
  @title = title
  @position = position
  @duration = duration
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



8
9
10
# File 'lib/ipodcastly/server/episode.rb', line 8

def duration
  @duration
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/ipodcastly/server/episode.rb', line 8

def id
  @id
end

#podcast_idObject (readonly)

Returns the value of attribute podcast_id.



8
9
10
# File 'lib/ipodcastly/server/episode.rb', line 8

def podcast_id
  @podcast_id
end

#positionObject (readonly)

Returns the value of attribute position.



8
9
10
# File 'lib/ipodcastly/server/episode.rb', line 8

def position
  @position
end

#titleObject (readonly)

Returns the value of attribute title.



8
9
10
# File 'lib/ipodcastly/server/episode.rb', line 8

def title
  @title
end

Instance Method Details

#saveObject



29
30
31
32
# File 'lib/ipodcastly/server/episode.rb', line 29

def save
  response = self.class.post("/episodes.json", :body => to_param)
  response.code == 200
end

#to_paramObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/ipodcastly/server/episode.rb', line 18

def to_param
  {
    :podcast_id => podcast_id,
    :episode => {
      :title => title,
      :position => position.to_i,
      :duration => duration.to_i
    }
  }
end