Class: Uber::Estimate

Inherits:
Base
  • Object
show all
Defined in:
lib/uber/models/estimate.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#attrs

Instance Method Summary collapse

Methods inherited from Base

#[], #initialize

Constructor Details

This class inherits a constructor from Uber::Base

Instance Attribute Details

#codeObject

Returns the value of attribute code.



4
5
6
# File 'lib/uber/models/estimate.rb', line 4

def code
  @code
end

#errorsObject

Returns the value of attribute errors.



4
5
6
# File 'lib/uber/models/estimate.rb', line 4

def errors
  @errors
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/uber/models/estimate.rb', line 4

def message
  @message
end

#pickup_estimateObject

Returns the value of attribute pickup_estimate.



4
5
6
# File 'lib/uber/models/estimate.rb', line 4

def pickup_estimate
  @pickup_estimate
end

#priceObject

Returns the value of attribute price.



4
5
6
# File 'lib/uber/models/estimate.rb', line 4

def price
  @price
end

#tripObject

Returns the value of attribute trip.



4
5
6
# File 'lib/uber/models/estimate.rb', line 4

def trip
  @trip
end

Instance Method Details

#errors?Boolean

Returns:



18
19
20
21
22
# File 'lib/uber/models/estimate.rb', line 18

def errors?
  multi_errors = @errors && @errors.size >= 1
  single_error = @code && !@code.empty? && @message && !@message.empty?
  multi_errors || single_error
end

#humanized_estimateObject



24
25
26
27
28
29
30
31
32
# File 'lib/uber/models/estimate.rb', line 24

def humanized_estimate
  unless pickup_estimate.nil?
    if pickup_estimate.to_i == 1
      "#{pickup_estimate} minute"
    else
      "#{pickup_estimate} minutes"
    end
  end
end