Class: Tilia::VObject::Splitter::VCard

Inherits:
Object
  • Object
show all
Includes:
SplitterInterface
Defined in:
lib/tilia/v_object/splitter/v_card.rb

Overview

Splitter.

This class is responsible for splitting up VCard objects.

It is assumed that the input stream contains 1 or more VCARD objects. This class checks for BEGIN:VCARD and END:VCARD and parses each encountered component individually.

Instance Method Summary collapse

Constructor Details

#initialize(input, options = 0) ⇒ VCard

Constructor.

The splitter should receive an readable file stream as it’s input.

Parameters:

  • input (resource)
  • options (Fixnum) (defaults to: 0)

    Parser options, see the OPTIONS constants.



29
30
31
32
# File 'lib/tilia/v_object/splitter/v_card.rb', line 29

def initialize(input, options = 0)
  @input = input
  @parser = Parser::MimeDir.new(input, options)
end

Instance Method Details

#nextSabre\VObject\Component?

Every time self.next is called, a new object will be parsed, until we hit the end of the stream.

When the end is reached, null will be returned.

Returns:



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/tilia/v_object/splitter/v_card.rb', line 40

def next
  begin
    object = @parser.parse

    unless object.is_a?(Component::VCard)
      fail ParseException, 'The supplied input contained non-VCARD data.'
    end
  rescue EofException
    return nil
  end

  object
end