Class: Netprint::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/netprint/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Options

Returns a new instance of Options.



5
6
7
8
9
10
11
12
13
# File 'lib/netprint/options.rb', line 5

def initialize(options = {})
  @options = {
    :paper_size  => PAPERSIZE::A4,
    :color       => COLOR::BW,
    :code_type   => CODE_TYPE::ALNUM,
    :secret_code => nil,
    :email       => nil
  }.merge(options)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/netprint/options.rb', line 3

def options
  @options
end

Instance Method Details

#apply(form) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/netprint/options.rb', line 15

def apply(form)
  check_radiobutton(form, 'yus-size',       options[:paper_size])
  check_radiobutton(form, 'iro-cl',         options[:color])
  check_radiobutton(form, 'yyk-type-cl',    options[:code_type])
  check_radiobutton(form, 'pin-num-set-fl', options[:secret_code] =~ /^\d{4}$/ ? '1' : '0')
  check_radiobutton(form, 'notice-onoff',   options[:email] ? '1' : '0')

  form['pin-no']         = options[:secret_code] if options[:secret_code] =~ /^\d{4}$/
  form['mail-adr-to-tx'] = options[:email]       if options[:email]
end