Class: Tilia::VObject::Reader
- Inherits:
-
Object
- Object
- Tilia::VObject::Reader
- Defined in:
- lib/tilia/v_object/reader.rb
Overview
iCalendar/vCard/jCal/jCard/xCal/xCard reader object.
This object provides a few (static) convenience methods to quickly access the parsers.
Constant Summary collapse
- OPTION_FORGIVING =
If this option is passed to the reader, it will be less strict about the validity of the lines.
1
- OPTION_IGNORE_INVALID_LINES =
If this option is turned on, any lines we cannot parse will be ignored by the reader.
2
Class Method Summary collapse
-
.read(data, options = 0, charset = 'UTF-8') ⇒ Document
Parses a vCard or iCalendar object, and returns the top component.
-
.read_json(data, options = 0) ⇒ Document
Parses a jCard or jCal object, and returns the top component.
-
.read_xml(data, options = 0) ⇒ Document
Parses a xCard or xCal object, and returns the top component.
Class Method Details
.read(data, options = 0, charset = 'UTF-8') ⇒ Document
Parses a vCard or iCalendar object, and returns the top component.
The options argument is a bitfield. Pass any of the OPTIONS constant to alter the parsers’ behaviour.
You can either supply a string, or a readable stream for input.
27 28 29 30 31 32 33 |
# File 'lib/tilia/v_object/reader.rb', line 27 def self.read(data, = 0, charset = 'UTF-8') parser = Parser::MimeDir.new parser.charset = charset result = parser.parse(data, ) result end |
.read_json(data, options = 0) ⇒ Document
Parses a jCard or jCal object, and returns the top component.
The options argument is a bitfield. Pass any of the OPTIONS constant to alter the parsers’ behaviour.
You can either a string, a readable stream, or an array for it’s input. Specifying the array is useful if json_decode was already called on the input.
48 49 50 51 52 53 |
# File 'lib/tilia/v_object/reader.rb', line 48 def self.read_json(data, = 0) parser = Parser::Json.new result = parser.parse(data, ) result end |
.read_xml(data, options = 0) ⇒ Document
Parses a xCard or xCal object, and returns the top component.
The options argument is a bitfield. Pass any of the OPTIONS constant to alter the parsers’ behaviour.
You can either supply a string, or a readable stream for input.
66 67 68 69 70 71 |
# File 'lib/tilia/v_object/reader.rb', line 66 def self.read_xml(data, = 0) parser = Parser::Xml.new result = parser.parse(data, ) result end |