class Dotremap::Item
Constants
- AVAILABLE_OPTIONS
Public Class Methods
new(name, options = {})
click to toggle source
# File lib/dotremap/item.rb, line 15 def initialize(name, options = {}) @skip_identifier = options.delete(:skip_identifier) if name property = Dotremap::Property.new("name", name) add_child(property) end options.each do |option, value| raise "Unavailable option: #{option}" unless AVAILABLE_OPTIONS.include?(option) property = Dotremap::Property.new(option, value) add_child(property) end end
Public Instance Methods
to_xml()
click to toggle source
Calls superclass method
Dotremap::XmlTree#to_xml
# File lib/dotremap/item.rb, line 31 def to_xml validate_name_existence generate_identifier unless @skip_identifier super end
Private Instance Methods
generate_identifier()
click to toggle source
# File lib/dotremap/item.rb, line 45 def generate_identifier properties = search_childs(Dotremap::Property) return if properties.map(&:attr).include?("identifier") name = properties.find { |p| p.attr == "name" } generated_identifier = name.value.gsub(/[^a-zA-Z]/, "_").downcase identifier = Dotremap::Property.new("identifier", "remap.#{generated_identifier}") childs[1, 0] = identifier end
validate_name_existence()
click to toggle source
# File lib/dotremap/item.rb, line 40 def validate_name_existence properties = search_childs(Dotremap::Property) raise "Name property does not exist" unless properties.map(&:attr).include?("name") end