Module: FeedMe
- Defined in:
- lib/feedme.rb
Defined Under Namespace
Classes: FeedData, FeedMeError, InfiniteCallLoopError, Parser, ParserBuilder, StrictParserBuilder
Constant Summary collapse
- VERSION =
"0.6.4"
- RSS =
constants for the feed type
:RSS
- RDF =
:RDF
- ATOM =
:ATOM
- CONTENT_KEY =
the key used to access the content element of a mixed tag
:content
Class Method Summary collapse
- .parse(source, options = {}) ⇒ Object
- .parse_strict(source, options = {}) ⇒ Object
- .pretty_to_s(obj, indent_step = 2, indent = 0, code = nil) ⇒ Object
Class Method Details
.parse(source, options = {}) ⇒ Object
40 41 42 |
# File 'lib/feedme.rb', line 40 def FeedMe.parse(source, ={}) ParserBuilder.new().parse(source) end |
.parse_strict(source, options = {}) ⇒ Object
44 45 46 |
# File 'lib/feedme.rb', line 44 def FeedMe.parse_strict(source, ={}) StrictParserBuilder.new().parse(source) end |
.pretty_to_s(obj, indent_step = 2, indent = 0, code = nil) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/feedme.rb', line 48 def FeedMe.pretty_to_s(obj, indent_step=2, indent=0, code=nil) new_indent = indent + indent_step space = ' ' * indent new_space = ' ' * new_indent str = '' if (obj.is_a?(FeedData) || obj.is_a?(Hash)) str << "#{obj.fm_tag_name} " if obj.is_a?(FeedData) str << "{" obj.each_with_index do |item, index| key, value = code.call(*item) if code str << "\n#{new_space}" str << FeedMe.pretty_to_s(key, indent_step, new_indent, code) str << " => " str << FeedMe.pretty_to_s(value, indent_step, new_indent, code) str << ',' unless index == obj.size-1 end str << "\n#{space}}" elsif obj.is_a?(Array) str << "[" obj.each_with_index do |value, index| str << "\n#{new_space}" str << FeedMe.pretty_to_s(value, indent_step, new_indent, code) str << ',' unless index == obj.size-1 end str << "\n#{space}]" else str << obj.to_s.strip.inspect end return str end |