Class: ElephantDrive::ResultExtractor
- Inherits:
-
Object
- Object
- ElephantDrive::ResultExtractor
- Defined in:
- lib/elephant-drive-service/result_extractor.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #ending_with(suffix) ⇒ Object
-
#initialize(action, response) ⇒ ResultExtractor
constructor
A new instance of ResultExtractor.
- #starting_with(prefix) ⇒ Object
Constructor Details
#initialize(action, response) ⇒ ResultExtractor
Returns a new instance of ResultExtractor.
5 6 7 8 9 10 |
# File 'lib/elephant-drive-service/result_extractor.rb', line 5 def initialize action, response @action = action @response_name = "#{@action}_response".to_sym @result_name = "#{@action}_result".to_sym @response = response end |
Instance Method Details
#[](name) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/elephant-drive-service/result_extractor.rb', line 12 def [] name case name when :result @response.body[@response_name][@result_name] else @response.body[@response_name][@result_name][name] end end |
#ending_with(suffix) ⇒ Object
21 22 23 24 25 |
# File 'lib/elephant-drive-service/result_extractor.rb', line 21 def ending_with suffix @response_name = "#{@action}_#{suffix}_response".to_sym @result_name = "#{@action}_#{suffix}_result".to_sym self end |
#starting_with(prefix) ⇒ Object
27 28 29 30 31 |
# File 'lib/elephant-drive-service/result_extractor.rb', line 27 def starting_with prefix @response_name = "#{prefix}_#{@action}_response".to_sym @result_name = "#{prefix}_#{@action}_result".to_sym self end |