Class: RSS::ITunesItemModel::ITunesDuration
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
|
|
Inherits: |
RSS::Element
|
Defined in: | lib/rss/itunes.rb |
Constant Summary
::RSS::Element - Inherited
GET_ATTRIBUTES, HAVE_CHILDREN_ELEMENTS, INDENT, MODELS, MUST_CALL_VALIDATORS, NEED_INITIALIZE_VARIABLES, PLURAL_FORMS, TO_ELEMENT_METHODS
::RSS::RSS09 - Included
Class Attribute Summary
::RSS::Element - Inherited
Class Method Summary
- .construct(hour, minute, second)
- .new(*args) ⇒ ITunesDuration constructor
- .parse(duration, do_validate = true)
- .required_prefix
- .required_uri
::RSS::Element - Inherited
::RSS::Utils::InheritedReader - Extended
::RSS::BaseModel - Extended
::RSS::Utils - Included
element_initialize_arguments? | This method is used inside of several different objects to determine if special behavior is needed in the constructor. |
get_file_and_line_from_caller | Returns an array of two elements: the filename where the calling method is located, and the line number where it is defined. |
h, | |
html_escape | Takes a string |
new_with_value_if_need | |
to_class_name | Given a |
Instance Attribute Summary
- #hour rw
- #hour=(hour) rw
- #minute rw
- #minute=(minute) rw
- #second rw
- #second=(second) rw
- #content=(value) (also: #value=) writeonly
::RSS::Element - Inherited
Instance Method Summary
- #full_name
- #value writeonly
- #maker_target(target) private
- #setup_maker_element(duration) private
- #update_content private
::RSS::Element - Inherited
::RSS::SetupMaker - Included
#setup_maker, #maker_target, #not_need_to_call_setup_maker_variables, #setup_maker_attributes, #setup_maker_element, #setup_maker_elements |
::RSS::Utils - Included
#element_initialize_arguments? | This method is used inside of several different objects to determine if special behavior is needed in the constructor. |
#get_file_and_line_from_caller | Returns an array of two elements: the filename where the calling method is located, and the line number where it is defined. |
#h, | |
#html_escape | Takes a string |
#new_with_value_if_need | |
#to_class_name | Given a |
Constructor Details
.new(*args) ⇒ ITunesDuration
# File 'lib/rss/itunes.rb', line 315
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
Class Method Details
.construct(hour, minute, second)
[ GitHub ].parse(duration, do_validate = true)
[ GitHub ]# File 'lib/rss/itunes.rb', line 277
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
[ GitHub ]# File 'lib/rss/itunes.rb', line 269
def required_prefix ITUNES_PREFIX end
.required_uri
[ GitHub ]# File 'lib/rss/itunes.rb', line 273
def required_uri ITUNES_URI end
Instance Attribute Details
#content=(value) (writeonly) Also known as: #value=
[ GitHub ]# File 'lib/rss/itunes.rb', line 336
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
#hour (rw)
[ GitHub ]#hour=(hour) (rw)
[ GitHub ]# File 'lib/rss/itunes.rb', line 352
def hour=(hour) @hour = @do_validate ? Integer(hour) : hour.to_i update_content hour end
#minute (rw)
[ GitHub ]#minute=(minute) (rw)
[ GitHub ]# File 'lib/rss/itunes.rb', line 358
def minute=(minute) @minute = @do_validate ? Integer(minute) : minute.to_i update_content minute end
#second (rw)
[ GitHub ]#second=(second) (rw)
[ GitHub ]# File 'lib/rss/itunes.rb', line 364
def second=(second) @second = @do_validate ? Integer(second) : second.to_i update_content second end
Instance Method Details
#full_name
[ GitHub ]# File 'lib/rss/itunes.rb', line 370
def full_name tag_name_with_prefix(ITUNES_PREFIX) end
#maker_target(target) (private)
[ GitHub ]# File 'lib/rss/itunes.rb', line 379
def maker_target(target) if @content target.itunes_duration {|duration| duration} else nil end end
#setup_maker_element(duration) (private)
[ GitHub ]# File 'lib/rss/itunes.rb', line 387
def setup_maker_element(duration) super(duration) duration.content = @content end
#update_content (private)
[ GitHub ]#value (writeonly)
[ GitHub ]# File 'lib/rss/itunes.rb', line 311
alias_method(:value, :content)