Module: InlineSvg::IOResource

Defined in:
lib/inline_svg/io_resource.rb

Class Method Summary collapse

Class Method Details

.===(object) ⇒ Object



3
4
5
# File 'lib/inline_svg/io_resource.rb', line 3

def self.===(object)
  object.is_a?(IO) || object.is_a?(StringIO)
end

.default_for(object) ⇒ Object



7
8
9
10
11
12
# File 'lib/inline_svg/io_resource.rb', line 7

def self.default_for(object)
  case object
  when StringIO then ''
  when IO then 1
  end
end

.read(object) ⇒ Object



14
15
16
17
18
19
# File 'lib/inline_svg/io_resource.rb', line 14

def self.read(object)
  start = object.pos
  str = object.read
  object.seek start
  str
end