Module: DLDInternet::DOctl::Compute::Domain::Records::MixIns::NoCommands
- Includes:
- MixIns::NoCommands
- Defined in:
- lib/dldinternet/doctl/compute/domain/records/mixins/no_commands.rb
Instance Method Summary collapse
Instance Method Details
#headers(command, obj) ⇒ Object
12 13 14 |
# File 'lib/dldinternet/doctl/compute/domain/records/mixins/no_commands.rb', line 12 def headers(command, obj) @headers[command].call(obj) end |
#record_from_options ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/dldinternet/doctl/compute/domain/records/mixins/no_commands.rb', line 41 def map = Hashie::Mash.new({ record_type: :type, record_name: :name, record_data: :data, record_priority: :priority, record_port: :port, record_weight: :weight, }) record = Hashie::Mash.new .each do |k,v| record[map[k]] = v if map.has_key?(k) end record end |
#records_formats ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dldinternet/doctl/compute/domain/records/mixins/no_commands.rb', line 16 def records_formats formats = Hashie::Mash.new({ ID: [ :id, '%-16s', :to_s ], Type: [ :type, '%-8s', :to_s ], Name: [ :name, '%-24s', :to_s ], Data: [ :data, '%-24s', :to_s ], Priority: [ :priority, '%-24s', :to_i ], Port: [ :port, '%-8s', :to_i ], Weight: [ :weight, '%-8s', :to_i ], }) format_names = [:format_string].split(/,/) format_templ = format_names.map { |name| formats[name][1] }.join('') @header = -> { sprintf(format_templ, *format_names) } @format = ->(o) { sprintf(format_templ, *(format_names.map{ |n| if o.respond_to?(formats[n][0]) o.send(formats[n][0]).send(formats[n][2]) else $stderr.write "#{n} not in #{o.class.name}::#{hash_it(o)}\n" '' end })) } end |