Class: Annal::Fetch::LocalFile

Inherits:
Object
  • Object
show all
Defined in:
lib/annal/fetch/local_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_identifier) ⇒ LocalFile

Returns a new instance of LocalFile.



5
6
7
8
9
10
11
# File 'lib/annal/fetch/local_file.rb', line 5

def initialize(file_identifier)
  self.file = if file_identifier.respond_to?(:read)
    file_identifier
  else
    File.open(file_identifier)
  end
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



4
5
6
# File 'lib/annal/fetch/local_file.rb', line 4

def file
  @file
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/annal/fetch/local_file.rb', line 4

def path
  @path
end

Instance Method Details

#local?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/annal/fetch/local_file.rb', line 13

def local?
  true
end

#readObject



17
18
19
# File 'lib/annal/fetch/local_file.rb', line 17

def read
  @read ||= file.read
end