class ContentstackUtils::Model::Metadata
Public Class Methods
new( element )
click to toggle source
# File lib/contentstack_utils/model/metadata.rb, line 5 def initialize( element ) if element.instance_of? Nokogiri::XML::Element @itemType = element.attribute('type') ? element.attribute('type').value : nil @styleType = element.attribute('sys-style-type') ? element.attribute('sys-style-type').value : nil @itemUid ||= (element.attribute('data-sys-entry-uid') ? element.attribute('data-sys-entry-uid').value : nil) || (element.attribute('data-sys-asset-uid') ? element.attribute('data-sys-asset-uid').value : nil) @contentTypeUid = element.attribute('data-sys-content-type-uid') ? element.attribute('data-sys-content-type-uid').value : nil @text = element.text @element = element @attributes = element else @itemType = element["attrs"]['type'] @styleType = element["attrs"]['display-type'] @itemUid ||= element["attrs"]['entry-uid'] || element["attrs"]['asset-uid'] @contentTypeUid = element["attrs"]['content-type-uid'] if element["children"] && element["children"].length() > 0 child = element["children"] for item in child do if item["type"] == nil && item["text"] @text = item["text"] end end end @element = element @attributes = element["attrs"] end end
Public Instance Methods
attributes()
click to toggle source
# File lib/contentstack_utils/model/metadata.rb, line 56 def attributes @attributes end
content_type_uid()
click to toggle source
# File lib/contentstack_utils/model/metadata.rb, line 44 def content_type_uid @contentTypeUid ? @contentTypeUid : nil end
element()
click to toggle source
# File lib/contentstack_utils/model/metadata.rb, line 52 def element @element end
get_attribute_value(string)
click to toggle source
# File lib/contentstack_utils/model/metadata.rb, line 60 def get_attribute_value(string) if @attributes.instance_of? Nokogiri::XML::Element @attributes.attribute(string) ? @attributes.attribute(string).value : nil else @attributes[string] end end
item_type()
click to toggle source
# File lib/contentstack_utils/model/metadata.rb, line 32 def item_type @itemType ? @itemType : nil end
item_uid()
click to toggle source
# File lib/contentstack_utils/model/metadata.rb, line 40 def item_uid @itemUid ? @itemUid : nil end
style_type()
click to toggle source
# File lib/contentstack_utils/model/metadata.rb, line 36 def style_type @styleType ? @styleType : nil end
text()
click to toggle source
# File lib/contentstack_utils/model/metadata.rb, line 48 def text @text end