Class: RSS::ITunesItemModel::ITunesDuration
Constant Summary
Constant Summary
Constants included from RSS09
RSS09::ELEMENTS, RSS09::NSPOOL
Constants inherited from Element
Element::GET_ATTRIBUTES, Element::HAVE_CHILDREN_ELEMENTS, Element::INDENT, Element::MODELS, Element::MUST_CALL_VALIDATORS, Element::NEED_INITIALIZE_VARIABLES, Element::PLURAL_FORMS, Element::TO_ELEMENT_METHODS
Instance Attribute Summary (collapse)
-
- (Object) hour
Returns the value of attribute hour.
-
- (Object) minute
Returns the value of attribute minute.
-
- (Object) second
Returns the value of attribute second.
Attributes inherited from Element
Class Method Summary (collapse)
- + (Object) construct(hour, minute, second)
- + (Object) parse(duration, do_validate = true)
- + (Object) required_prefix
- + (Object) required_uri
Instance Method Summary (collapse)
- - (Object) content=(value) (also: #value=)
- - (Object) full_name
-
- (ITunesDuration) initialize(*args)
constructor
A new instance of ITunesDuration.
Methods included from RSS09
Methods inherited from Element
add_have_children_element, add_need_initialize_variable, add_plural_form, add_to_element_method, content_setup, #convert, #converter=, def_corresponded_attr_reader, def_corresponded_attr_writer, get_attributes, have_children_elements, have_content?, #have_xml_content?, inherited, inherited_base, install_get_attribute, install_model, install_must_call_validator, install_ns, models, must_call_validators, #need_base64_encode?, need_initialize_variables, need_parent?, plural_forms, #set_next_element, tag_name, #tag_name, to_element_methods, #to_s, #valid?, #validate, #validate_for_stream
Methods included from Utils::InheritedReader
#inherited_array_reader, #inherited_hash_reader, #inherited_reader
Methods included from BaseModel
#install_date_element, #install_have_child_element, #install_have_children_element, #install_text_element
Methods included from Utils
#element_initialize_arguments?, #get_file_and_line_from_caller, #html_escape, #new_with_value_if_need, #to_class_name
Methods included from SetupMaker
Constructor Details
- (ITunesDuration) initialize(*args)
A new instance of ITunesDuration
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/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 |
Instance Attribute Details
- (Object) hour
Returns the value of attribute hour
311 312 313 |
# File 'lib/rss/itunes.rb', line 311 def hour @hour end |
- (Object) minute
Returns the value of attribute minute
311 312 313 |
# File 'lib/rss/itunes.rb', line 311 def minute @minute end |
- (Object) second
Returns the value of attribute second
311 312 313 |
# File 'lib/rss/itunes.rb', line 311 def second @second end |
Class Method Details
+ (Object) construct(hour, minute, second)
294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/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 |
+ (Object) parse(duration, do_validate = true)
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/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 |
+ (Object) required_prefix
266 267 268 |
# File 'lib/rss/itunes.rb', line 266 def required_prefix ITUNES_PREFIX end |
+ (Object) required_uri
270 271 272 |
# File 'lib/rss/itunes.rb', line 270 def required_uri ITUNES_URI end |
Instance Method Details
- (Object) content=(value) Also known as: value=
333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
# File 'lib/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 |
- (Object) full_name
367 368 369 |
# File 'lib/rss/itunes.rb', line 367 def full_name tag_name_with_prefix(ITUNES_PREFIX) end |