Sha256: 742e4f7244f5e10aa27ee1a638ddd70d58ae1ccf0f540e559a385243a6f8f748

Contents?: true

Size: 683 Bytes

Versions: 1

Compression:

Stored size: 683 Bytes

Contents

module Alma
  class RenewalResponse

    include Alma::Error

    def initialize(response)
      @response = response
      @success  = response.fetch('item_loan', {})
      @renewed  = error.empty?
    end

    def renewed?
      @renewed
    end

    def due_date
      @success.fetch('due_date', '')
    end


    def due_date_pretty
      Time.parse(due_date).strftime('%m-%e-%y %H:%M')
    end

    def item_title
      if @success
        @success['title']
      else
        'This Item'
      end
    end

    def message
      if @success
        "#{item_title} is now due #{new_due_date}"
      else
        "#{item_title} could not be renewed."
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alma-0.2.3 lib/alma/renewal_response.rb