mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rss/rss.rb: RSS::Element#initialize accepts initial
attributes. * lib/rss/0.9.rb: ditto. * lib/rss/1.0.rb: ditto. * lib/rss/2.0.rb: ditto. * lib/rss/dublincore.rb: ditto. * lib/rss/image.rb: ditto. * lib/rss/taxonomy.rb: ditto. * lib/rss/trackback.rb: ditto. * lib/rss/utils.rb: added Utils.element_initialize_arguments? to detect backward compatibility initial arguments. * lib/rss/parser.rb: user initial attributes to initialize RSS::Element. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e6037e6111
commit
63c3fd6aa2
11 changed files with 256 additions and 120 deletions
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
||||||
|
Sun Jun 18 22:36:13 2006 Kouhei Sutou <kou@cozmixng.org>
|
||||||
|
|
||||||
|
* lib/rss/rss.rb: RSS::Element#initialize accepts initial
|
||||||
|
attributes.
|
||||||
|
* lib/rss/0.9.rb: ditto.
|
||||||
|
* lib/rss/1.0.rb: ditto.
|
||||||
|
* lib/rss/2.0.rb: ditto.
|
||||||
|
* lib/rss/dublincore.rb: ditto.
|
||||||
|
* lib/rss/image.rb: ditto.
|
||||||
|
* lib/rss/taxonomy.rb: ditto.
|
||||||
|
* lib/rss/trackback.rb: ditto.
|
||||||
|
|
||||||
|
* lib/rss/utils.rb: added Utils.element_initialize_arguments? to
|
||||||
|
detect backward compatibility initial arguments.
|
||||||
|
|
||||||
|
* lib/rss/parser.rb: user initial attributes to initialize
|
||||||
|
RSS::Element.
|
||||||
|
|
||||||
Sun Jun 18 18:24:42 2006 Kouhei Sutou <kou@cozmixng.org>
|
Sun Jun 18 18:24:42 2006 Kouhei Sutou <kou@cozmixng.org>
|
||||||
|
|
||||||
* lib/rss/converter.rb: use NKF for Uconv fallback.
|
* lib/rss/converter.rb: use NKF for Uconv fallback.
|
||||||
|
|
101
lib/rss/0.9.rb
101
lib/rss/0.9.rb
|
@ -149,10 +149,6 @@ module RSS
|
||||||
install_model(name, occurs)
|
install_model(name, occurs)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize()
|
|
||||||
super()
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_s(need_convert=true, indent='')
|
def to_s(need_convert=true, indent='')
|
||||||
rv = tag(indent) do |next_indent|
|
rv = tag(indent) do |next_indent|
|
||||||
[
|
[
|
||||||
|
@ -274,9 +270,13 @@ module RSS
|
||||||
|
|
||||||
content_setup
|
content_setup
|
||||||
|
|
||||||
def initialize(content=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.content = content
|
self.content = args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -319,9 +319,13 @@ module RSS
|
||||||
|
|
||||||
content_setup(:integer)
|
content_setup(:integer)
|
||||||
|
|
||||||
def initialize(content=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.content = content
|
self.content = args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -344,15 +348,18 @@ module RSS
|
||||||
install_model(name, "?")
|
install_model(name, "?")
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(url=nil, title=nil, link=nil, width=nil, height=nil,
|
def initialize(*args)
|
||||||
description=nil)
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.url = url
|
self.url = args[0]
|
||||||
self.title = title
|
self.title = args[1]
|
||||||
self.link = link
|
self.link = args[2]
|
||||||
self.width = width
|
self.width = args[3]
|
||||||
self.height = height
|
self.height = args[4]
|
||||||
self.description = description
|
self.description = args[5]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(need_convert=true, indent='')
|
def to_s(need_convert=true, indent='')
|
||||||
|
@ -399,13 +406,17 @@ module RSS
|
||||||
install_get_attribute(name, uri, required, type)
|
install_get_attribute(name, uri, required, type)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(domain=nil, port=nil, path=nil, rp=nil, protocol=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.domain = domain
|
self.domain = args[0]
|
||||||
self.port = port
|
self.port = args[1]
|
||||||
self.path = path
|
self.path = args[2]
|
||||||
self.registerProcedure = rp
|
self.registerProcedure = args[3]
|
||||||
self.protocol = protocol
|
self.protocol = args[4]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(need_convert=true, indent='')
|
def to_s(need_convert=true, indent='')
|
||||||
|
@ -514,10 +525,14 @@ module RSS
|
||||||
|
|
||||||
content_setup
|
content_setup
|
||||||
|
|
||||||
def initialize(url=nil, content=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.url = url
|
self.url = args[0]
|
||||||
self.content = content
|
self.content = args[1]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -554,11 +569,15 @@ module RSS
|
||||||
install_get_attribute(name, uri, required, type)
|
install_get_attribute(name, uri, required, type)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(url=nil, length=nil, type=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.url = url
|
self.url = args[0]
|
||||||
self.length = length
|
self.length = args[1]
|
||||||
self.type = type
|
self.type = args[2]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(need_convert=true, indent='')
|
def to_s(need_convert=true, indent='')
|
||||||
|
@ -599,10 +618,14 @@ module RSS
|
||||||
|
|
||||||
content_setup
|
content_setup
|
||||||
|
|
||||||
def initialize(domain=nil, content=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.domain = domain
|
self.domain = args[0]
|
||||||
self.content = content
|
self.content = args[1]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -634,12 +657,16 @@ module RSS
|
||||||
install_model(name, nil)
|
install_model(name, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(title=nil, description=nil, name=nil, link=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.title = title
|
self.title = args[0]
|
||||||
self.description = description
|
self.description = args[1]
|
||||||
self.name = name
|
self.name = args[2]
|
||||||
self.link = link
|
self.link = args[3]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(need_convert=true, indent='')
|
def to_s(need_convert=true, indent='')
|
||||||
|
|
|
@ -107,9 +107,13 @@ module RSS
|
||||||
install_get_attribute(name, uri, required)
|
install_get_attribute(name, uri, required)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(resource=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.resource = resource
|
self.resource = args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_name
|
def full_name
|
||||||
|
@ -148,9 +152,13 @@ module RSS
|
||||||
|
|
||||||
install_must_call_validator('rdf', ::RSS::RDF::URI)
|
install_must_call_validator('rdf', ::RSS::RDF::URI)
|
||||||
|
|
||||||
def initialize(li=[])
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
@li = li
|
@li = args[0] if args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(need_convert=true, indent='')
|
def to_s(need_convert=true, indent='')
|
||||||
|
@ -208,9 +216,13 @@ module RSS
|
||||||
|
|
||||||
install_must_call_validator('rdf', ::RSS::RDF::URI)
|
install_must_call_validator('rdf', ::RSS::RDF::URI)
|
||||||
|
|
||||||
def initialize(li=[])
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
@li = li
|
@li = args[0] if args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(need_convert=true, indent='')
|
def to_s(need_convert=true, indent='')
|
||||||
|
@ -287,9 +299,13 @@ module RSS
|
||||||
install_model(tag, occurs)
|
install_model(tag, occurs)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(about=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.about = about
|
self.about = args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(need_convert=true, indent='')
|
def to_s(need_convert=true, indent='')
|
||||||
|
@ -358,9 +374,13 @@ module RSS
|
||||||
install_get_attribute(name, uri, required)
|
install_get_attribute(name, uri, required)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(resource=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.resource = resource
|
self.resource = args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(need_convert=true, indent='')
|
def to_s(need_convert=true, indent='')
|
||||||
|
@ -395,9 +415,13 @@ module RSS
|
||||||
install_get_attribute(name, uri, required)
|
install_get_attribute(name, uri, required)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(resource=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.resource = resource
|
self.resource = args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(need_convert=true, indent='')
|
def to_s(need_convert=true, indent='')
|
||||||
|
@ -432,9 +456,14 @@ module RSS
|
||||||
|
|
||||||
install_must_call_validator('rdf', ::RSS::RDF::URI)
|
install_must_call_validator('rdf', ::RSS::RDF::URI)
|
||||||
|
|
||||||
def initialize(seq=Seq.new)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
@Seq = seq
|
self.Seq = args[0]
|
||||||
|
end
|
||||||
|
self.Seq ||= Seq.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(need_convert=true, indent='')
|
def to_s(need_convert=true, indent='')
|
||||||
|
@ -503,9 +532,13 @@ module RSS
|
||||||
install_model(tag, occurs)
|
install_model(tag, occurs)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(about=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.about = about
|
self.about = args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(need_convert=true, indent='')
|
def to_s(need_convert=true, indent='')
|
||||||
|
@ -573,9 +606,13 @@ module RSS
|
||||||
install_model(tag, occurs)
|
install_model(tag, occurs)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(about=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.about = about
|
self.about = args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(need_convert=true, indent='')
|
def to_s(need_convert=true, indent='')
|
||||||
|
@ -648,9 +685,13 @@ module RSS
|
||||||
install_model(tag, occurs)
|
install_model(tag, occurs)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(about=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.about = about
|
self.about = args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s(need_convert=true, indent='')
|
def to_s(need_convert=true, indent='')
|
||||||
|
|
|
@ -131,10 +131,14 @@ EOT
|
||||||
|
|
||||||
content_setup
|
content_setup
|
||||||
|
|
||||||
def initialize(isPermaLink=nil, content=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.isPermaLink = isPermaLink
|
self.isPermaLink = args[0]
|
||||||
self.content = content
|
self.content = args[1]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_method :_PermaLink?, :PermaLink?
|
alias_method :_PermaLink?, :PermaLink?
|
||||||
|
|
|
@ -97,9 +97,13 @@ module RSS
|
||||||
alias_method(:value, :content)
|
alias_method(:value, :content)
|
||||||
alias_method(:value=, :content=)
|
alias_method(:value=, :content=)
|
||||||
|
|
||||||
def initialize(content=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.content = content
|
self.content = args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_name
|
def full_name
|
||||||
|
|
|
@ -75,10 +75,14 @@ module RSS
|
||||||
alias height= image_height=
|
alias height= image_height=
|
||||||
alias height image_height
|
alias height image_height
|
||||||
|
|
||||||
def initialize(about=nil, resource=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.about = about
|
self.about = args[0]
|
||||||
self.resource = resource
|
self.resource = args[1]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_name
|
def full_name
|
||||||
|
@ -179,10 +183,14 @@ module RSS
|
||||||
alias image_size= size=
|
alias image_size= size=
|
||||||
alias image_size size
|
alias image_size size
|
||||||
|
|
||||||
def initialize(about=nil, size=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
self.about = about
|
self.about = args[0]
|
||||||
self.size = size
|
self.size = args[1]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_name
|
def full_name
|
||||||
|
|
|
@ -377,8 +377,7 @@ module RSS
|
||||||
|
|
||||||
check_ns(tag_name, prefix, ns, klass.required_uri)
|
check_ns(tag_name, prefix, ns, klass.required_uri)
|
||||||
|
|
||||||
args = []
|
attributes = {}
|
||||||
|
|
||||||
klass.get_attributes.each do |a_name, a_uri, required|
|
klass.get_attributes.each do |a_name, a_uri, required|
|
||||||
|
|
||||||
if a_uri.is_a?(String) or !a_uri.respond_to?(:include?)
|
if a_uri.is_a?(String) or !a_uri.respond_to?(:include?)
|
||||||
|
@ -407,12 +406,11 @@ module RSS
|
||||||
raise MissingAttributeError.new(tag_name, a_name)
|
raise MissingAttributeError.new(tag_name, a_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
args << val
|
attributes[a_name] = val
|
||||||
end
|
end
|
||||||
|
|
||||||
previous = @last_element
|
previous = @last_element
|
||||||
next_element = klass.new(*args)
|
next_element = klass.new(@do_validate, attributes)
|
||||||
next_element.do_validate = @do_validate
|
|
||||||
previous.instance_eval {set_next_element(tag_name, next_element)}
|
previous.instance_eval {set_next_element(tag_name, next_element)}
|
||||||
@last_element = next_element
|
@last_element = next_element
|
||||||
@proc_stack.push Proc.new { |text, tags|
|
@proc_stack.push Proc.new { |text, tags|
|
||||||
|
|
|
@ -489,6 +489,7 @@ EOC
|
||||||
alias_method "\#{$POSTMATCH}?", name
|
alias_method "\#{$POSTMATCH}?", name
|
||||||
end
|
end
|
||||||
GET_ATTRIBUTES << [name, uri, required]
|
GET_ATTRIBUTES << [name, uri, required]
|
||||||
|
add_need_initialize_variable(disp_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.def_corresponded_attr_writer(name, type=nil, disp_name=name)
|
def self.def_corresponded_attr_writer(name, type=nil, disp_name=name)
|
||||||
|
@ -552,10 +553,10 @@ EOC
|
||||||
|
|
||||||
attr_accessor :do_validate
|
attr_accessor :do_validate
|
||||||
|
|
||||||
def initialize(do_validate=true)
|
def initialize(do_validate=true, attrs={})
|
||||||
@converter = nil
|
@converter = nil
|
||||||
@do_validate = do_validate
|
@do_validate = do_validate
|
||||||
initialize_variables
|
initialize_variables(attrs)
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_name
|
def tag_name
|
||||||
|
@ -605,10 +606,19 @@ EOC
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def initialize_variables
|
def initialize_variables(attrs)
|
||||||
|
normalized_attrs = {}
|
||||||
|
attrs.each do |key, value|
|
||||||
|
normalized_attrs[key.to_s] = value
|
||||||
|
end
|
||||||
self.class.need_initialize_variables.each do |variable_name|
|
self.class.need_initialize_variables.each do |variable_name|
|
||||||
|
value = normalized_attrs[variable_name.to_s]
|
||||||
|
if value
|
||||||
|
__send__("#{variable_name}=", value)
|
||||||
|
else
|
||||||
instance_eval("@#{variable_name} = nil")
|
instance_eval("@#{variable_name} = nil")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
initialize_have_children_elements
|
initialize_have_children_elements
|
||||||
@content = "" if self.class.have_content?
|
@content = "" if self.class.have_content?
|
||||||
end
|
end
|
||||||
|
|
|
@ -68,9 +68,14 @@ module RSS
|
||||||
|
|
||||||
install_must_call_validator('rdf', ::RSS::RDF::URI)
|
install_must_call_validator('rdf', ::RSS::RDF::URI)
|
||||||
|
|
||||||
def initialize(bag=Bag.new)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
@Bag = bag
|
self.Bag = args[0]
|
||||||
|
end
|
||||||
|
self.Bag ||= Bag.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_name
|
def full_name
|
||||||
|
@ -155,9 +160,13 @@ module RSS
|
||||||
install_get_attribute("about", ::RSS::RDF::URI, true)
|
install_get_attribute("about", ::RSS::RDF::URI, true)
|
||||||
install_text_element("#{TAXO_PREFIX}_link")
|
install_text_element("#{TAXO_PREFIX}_link")
|
||||||
|
|
||||||
def initialize(about=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
@about = about
|
self.about = args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_name
|
def full_name
|
||||||
|
|
|
@ -136,9 +136,13 @@ module RSS
|
||||||
alias_method(:value, :resource)
|
alias_method(:value, :resource)
|
||||||
alias_method(:value=, :resource=)
|
alias_method(:value=, :resource=)
|
||||||
|
|
||||||
def initialize(resource=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
@resource = resource
|
self.resource = args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_name
|
def full_name
|
||||||
|
@ -186,9 +190,13 @@ module RSS
|
||||||
alias_method(:value, :resource)
|
alias_method(:value, :resource)
|
||||||
alias_method(:value=, :resource=)
|
alias_method(:value=, :resource=)
|
||||||
|
|
||||||
def initialize(resource=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
@resource = resource
|
self.resource = args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_name
|
def full_name
|
||||||
|
@ -245,9 +253,13 @@ module RSS
|
||||||
alias_method(:value, :content)
|
alias_method(:value, :content)
|
||||||
alias_method(:value=, :content=)
|
alias_method(:value=, :content=)
|
||||||
|
|
||||||
def initialize(content=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
@content = content
|
self.content = args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_name
|
def full_name
|
||||||
|
@ -278,9 +290,13 @@ module RSS
|
||||||
alias_method(:value, :content)
|
alias_method(:value, :content)
|
||||||
alias_method(:value=, :content=)
|
alias_method(:value=, :content=)
|
||||||
|
|
||||||
def initialize(content=nil)
|
def initialize(*args)
|
||||||
|
if Utils.element_initialize_arguments?(args)
|
||||||
|
super
|
||||||
|
else
|
||||||
super()
|
super()
|
||||||
@content = content
|
self.content = args[0]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_name
|
def full_name
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
module RSS
|
module RSS
|
||||||
|
|
||||||
module Utils
|
module Utils
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
def to_class_name(name)
|
def to_class_name(name)
|
||||||
name.split(/_/).collect do |part|
|
name.split(/_/).collect do |part|
|
||||||
|
@ -26,6 +24,9 @@ module RSS
|
||||||
klass.new(value)
|
klass.new(value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
def element_initialize_arguments?(args)
|
||||||
|
[true, false].include?(args[0]) and args[1].is_a?(Hash)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue