Sha256: 38c7d328c2d2f351ddd79ef823b99beacfdd5de31de5c1130271dc798224019e

Contents?: true

Size: 735 Bytes

Versions: 5

Compression:

Stored size: 735 Bytes

Contents

module Netprint
  class URL
    def initialize(session_id, userid, password)
      @session_id = session_id
      @userid     = userid
      @password   = password
    end

    def login
      expand(:i => @userid, :p => @password)
    end

    def upload
      expand(:s => @session_id, :c => 0, :m => 1)
    end

    def list
      expand(:s => @session_id, :c => 0, :m => 0)
    end

    private

    def expand(params)
      Addressable::Template.new(template).
        expand(params).
        to_str
    end

    def template
      Addressable::VERSION::STRING >= '2.2.7' ?
        'https://www.printing.ne.jp/cgi-bin/mn.cgi{?i,p,s,c,m}' :
        'https://www.printing.ne.jp/cgi-bin/mn.cgi?{-join|&|i,p,s,c,m}'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
netprint-0.2.0 lib/netprint/url.rb
netprint-0.1.1 lib/netprint/url.rb
netprint-0.1.0 lib/netprint/url.rb
netprint-0.0.4 lib/netprint/url.rb
netprint-0.0.3 lib/netprint/url.rb