class Tilia::VObject::Splitter::VCard

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.

Public Class Methods

new(input, options = 0) click to toggle source

Constructor.

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

@param [resource] input @param [Fixnum] options Parser options, see the OPTIONS constants.

# 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

Public Instance Methods

next() click to toggle source

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.

@return [SabreVObjectComponent, nil]

# 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