Class: SeriesTimer::Episode

Inherits:
Struct
  • Object
show all
Defined in:
lib/series_timer/episode.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#date_rawObject

Returns the value of attribute date_raw

Returns:

  • (Object)

    the current value of date_raw



2
3
4
# File 'lib/series_timer/episode.rb', line 2

def date_raw
  @date_raw
end

#number_rawObject

Returns the value of attribute number_raw

Returns:

  • (Object)

    the current value of number_raw



2
3
4
# File 'lib/series_timer/episode.rb', line 2

def number_raw
  @number_raw
end

#seasonObject

Returns the value of attribute season

Returns:

  • (Object)

    the current value of season



2
3
4
# File 'lib/series_timer/episode.rb', line 2

def season
  @season
end

#serieObject

Returns the value of attribute serie

Returns:

  • (Object)

    the current value of serie



2
3
4
# File 'lib/series_timer/episode.rb', line 2

def serie
  @serie
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



2
3
4
# File 'lib/series_timer/episode.rb', line 2

def title
  @title
end

Instance Method Details

#dateObject



4
5
6
# File 'lib/series_timer/episode.rb', line 4

def date
  @date ||= Date.parse date_raw
end

#diffdaysObject



8
9
10
11
# File 'lib/series_timer/episode.rb', line 8

def diffdays
  days = (date - Date.today).to_i
  "#{days.abs} days#{days < 0 ? ' ago':''}"
end

#empty?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/series_timer/episode.rb', line 17

def empty?
  number_raw.nil?
end

#numberObject



13
14
15
# File 'lib/series_timer/episode.rb', line 13

def number
  @number ||= number_raw.to_i
end

#to_sObject



21
22
23
# File 'lib/series_timer/episode.rb', line 21

def to_s
  "[#{serie}] S%02dE%02d\t #{title}\t #{date} (#{diffdays})"  % [ season, number ]
end