lib/csl/info.rb in csl-1.0.0.pre2 vs lib/csl/info.rb in csl-1.0.0.pre3
- old
+ new
@@ -4,12 +4,57 @@
attr_children :title, :'title-short', :id, :issn, :eissn, :issnl,
:link, :author, :contributor, :category, :published, :summary,
:updated, :rights, :'link-dependent-style'
- alias contributors contributor
+ alias_child :contributors, :contributor
+ alias_child :authors, :contributor
+ alias_child :links, :link
+ def initialize(attributes = {})
+ super(attributes, &nil)
+ children[:link] = []
+
+ yield self if block_given?
+ end
+ # @!attribute self_link
+ # @return [String,nil] the style's URI
+
+ # @!attribute template_link
+ # @return [String,nil] URI of the style from which the current style is derived
+
+ # @!attribute documentation_link
+ # @return [String,nil] URI of style documentation
+ [:self, :template, :documentation].each do |type|
+ method_id = "#{type}_link"
+
+ define_method method_id do
+ link = links.detect { |l| l.match? :rel => type.to_s }
+ link.nil? ? nil : link[:href]
+ end
+
+ alias_method "has_#{method_id}?", method_id
+
+ define_method "#{method_id}=" do |value|
+ link = links.detect { |l| l.match? :rel => type.to_s }
+
+ if link.nil?
+ set_child_link :href => value.to_s, :rel => type.to_s
+ else
+ link[:href] = value.to_s
+ link
+ end
+ end
+ end
+
+ def id
+ children[:id]
+ end
+
+ alias id= set_child_id
+
+
class Contributor < Node
attr_children :name, :email, :uri
end
class Author < Node
\ No newline at end of file