Class: Higo::Transport::File
- Inherits:
-
Object
- Object
- Higo::Transport::File
- Defined in:
- lib/higo/transport/file.rb
Instance Attribute Summary collapse
-
#_raw_file ⇒ Object
Returns the value of attribute _raw_file.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#responses ⇒ Object
Returns the value of attribute responses.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #finish ⇒ Object
-
#initialize(path: nil) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(path: nil) ⇒ File
Returns a new instance of File.
8 9 10 11 12 |
# File 'lib/higo/transport/file.rb', line 8 def initialize(path: nil) @path = find_file(path) @_raw_file = {} @responses = {} end |
Instance Attribute Details
#_raw_file ⇒ Object
Returns the value of attribute _raw_file.
6 7 8 |
# File 'lib/higo/transport/file.rb', line 6 def _raw_file @_raw_file end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/higo/transport/file.rb', line 5 def path @path end |
#responses ⇒ Object
Returns the value of attribute responses.
6 7 8 |
# File 'lib/higo/transport/file.rb', line 6 def responses @responses end |
Class Method Details
.transport(path) ⇒ Object
14 15 16 17 18 |
# File 'lib/higo/transport/file.rb', line 14 def self.transport(path) file = new(path) file._raw_file = file.call file end |
Instance Method Details
#call ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/higo/transport/file.rb', line 20 def call Fiber.new do ::File.open(path, 'r') do |f| f.readlines.map end end end |
#finish ⇒ Object
28 29 30 31 32 33 |
# File 'lib/higo/transport/file.rb', line 28 def finish _raw_file.resume.map do |val| responses.merge!(Hash[*process_value(val)]) end responses end |