Extended maintenance of Ruby 1.9.3 ended on February 23, 2015. Read more

In Files

  • rss/itunes.rb

Class/Module Index [+]

Quicksearch

RSS::ITunesItemModel::ITunesDuration

Attributes

hour[R]
minute[R]
second[R]

Public Class Methods

construct(hour, minute, second) click to toggle source
 
               # File rss/itunes.rb, line 294
def construct(hour, minute, second)
  components = [minute, second]
  if components.include?(nil)
    nil
  else
    components.unshift(hour) if hour and hour > 0
    components.collect do |component|
      "%02d" % component
    end.join(":")
  end
end
            
new(*args) click to toggle source
 
               # File rss/itunes.rb, line 312
def initialize(*args)
  if Utils.element_initialize_arguments?(args)
    super
  else
    super()
    args = args[0] if args.size == 1 and args[0].is_a?(Array)
    if args.size == 1
      self.content = args[0]
    elsif args.size > 3
      raise ArgumentError,
              "must be (do_validate, params), (content), " +
              "(minute, second), ([minute, second]), "  +
              "(hour, minute, second) or ([hour, minute, second]): " +
              args.inspect
    else
      @second, @minute, @hour = args.reverse
      update_content
    end
  end
end
            
parse(duration, do_validate=true) click to toggle source
 
               # File rss/itunes.rb, line 274
def parse(duration, do_validate=true)
  if do_validate and /\A(?:
                          \d?\d:[0-5]\d:[0-5]\d|
                          [0-5]?\d:[0-5]\d
                        )\z/x !~ duration
    raise ArgumentError,
            "must be one of HH:MM:SS, H:MM:SS, MM::SS, M:SS: " +
            duration.inspect
  end

  components = duration.split(':')
  components[3..-1] = nil if components.size > 3

  components.unshift("00") until components.size == 3

  components.collect do |component|
    component.to_i
  end
end
            
required_prefix() click to toggle source
 
               # File rss/itunes.rb, line 266
def required_prefix
  ITUNES_PREFIX
end
            
required_uri() click to toggle source
 
               # File rss/itunes.rb, line 270
def required_uri
  ITUNES_URI
end
            

Public Instance Methods

content=(value) click to toggle source
 
               # File rss/itunes.rb, line 333
def content=(value)
  if value.nil?
    @content = nil
  elsif value.is_a?(self.class)
    self.content = value.content
  else
    begin
      @hour, @minute, @second = self.class.parse(value, @do_validate)
    rescue ArgumentError
      raise NotAvailableValueError.new(tag_name, value)
    end
    @content = value
  end
end
            
Also aliased as: value=
full_name() click to toggle source
 
               # File rss/itunes.rb, line 367
def full_name
  tag_name_with_prefix(ITUNES_PREFIX)
end
            
hour=(hour) click to toggle source
 
               # File rss/itunes.rb, line 349
def hour=(hour)
  @hour = @do_validate ? Integer(hour) : hour.to_i
  update_content
  hour
end
            
minute=(minute) click to toggle source
 
               # File rss/itunes.rb, line 355
def minute=(minute)
  @minute = @do_validate ? Integer(minute) : minute.to_i
  update_content
  minute
end
            
second=(second) click to toggle source
 
               # File rss/itunes.rb, line 361
def second=(second)
  @second = @do_validate ? Integer(second) : second.to_i
  update_content
  second
end
            
value=(value) click to toggle source
Alias for: content=

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.