Class: NtaRuby::Options
- Inherits:
-
Object
- Object
- NtaRuby::Options
- Defined in:
- lib/nta_ruby/options.rb
Constant Summary collapse
- SEARCH_CONDITION_KINDS =
%w[ number history from to req_type resp_type name address mode kind close divide ]
Instance Method Summary collapse
-
#initialize(type:, **option) ⇒ Options
constructor
A new instance of Options.
- #to_h ⇒ Object
Constructor Details
#initialize(type:, **option) ⇒ Options
Returns a new instance of Options.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/nta_ruby/options.rb', line 22 def initialize(type:, **option) @number = option[:number] if option[:number] @history = option[:history] === true ? 1 : 0 @from = option[:from]&.strftime('%Y-%m-%d') if option[:from] @to = option[:to]&.strftime('%Y-%m-%d') if option[:to] @req_type = type @resp_type = '02' @name = option[:name] if option[:name] @address = option[:address] if option[:address] @mode = option[:mode] if option[:mode] @kind = option[:kind] if option[:kind] @close = option[:close] === true ? 1 : 0 @divide = option[:divide]&.to_i || 1 end |
Instance Method Details
#to_h ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/nta_ruby/options.rb', line 37 def to_h search_hash = { number: number, from: from, to: to, type: resp_type, name: name, address: address, mode: mode, kind: kind, close: close, divide: divide } if req_type == :number search_hash.merge({ history: history }) elsif req_type == :name search_hash.merge({ change: change }) else search_hash end end |