Class: Vcard::Attachment::Uri

Inherits:
Object
  • Object
show all
Defined in:
lib/vcard/attachment.rb

Overview

Encapsulates a URI and implements some methods of String.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, format) ⇒ Uri

:nodoc:



65
66
67
68
# File 'lib/vcard/attachment.rb', line 65

def initialize(uri, format) #:nodoc:
  @uri = uri
  @format = format
end

Instance Attribute Details

#formatObject (readonly)

The format of the data referred to by the URI. See Attachment.



75
76
77
# File 'lib/vcard/attachment.rb', line 75

def format
  @format
end

#uriObject (readonly)

The URI value.



71
72
73
# File 'lib/vcard/attachment.rb', line 71

def uri
  @uri
end

Instance Method Details

#inspectObject

:nodoc:



88
89
90
91
92
# File 'lib/vcard/attachment.rb', line 88

def inspect #:nodoc:
  s = "<#{self.class.to_s}: #{uri.inspect}>"
  s << ", #{@format.inspect}" if @format
  s
end

#to_ioObject

Return an IO object from opening the URI. See open-uri for more information.



79
80
81
# File 'lib/vcard/attachment.rb', line 79

def to_io
  open(@uri)
end

#to_sObject

Return the String from reading the IO object to end-of-data.



84
85
86
# File 'lib/vcard/attachment.rb', line 84

def to_s
  to_io.read(nil)
end