class Idcf::Cli::Lib::Convert::Helper
format helper
Constants
- FILTER_OPTION
Public Instance Methods
filter(data, o, table_flag)
click to toggle source
data convert
@param data [Hash] @param o [Hash] format @param table_flag [Boolean] @return Hash
# File lib/idcf/cli/lib/convert/helper.rb, line 52 def filter(data, o, table_flag) result = data.deep_dup FILTER_OPTION.each do |k| next if o[k].nil? || o[k].empty? fo = { table_flag: table_flag } result = cls_load("Filter::#{k.to_s.classify}Filter").new(fo).filter(result, o[k]) end result end
filter_target?(o)
click to toggle source
is filter target @param o [Hash] @return Boolean
# File lib/idcf/cli/lib/convert/helper.rb, line 26 def filter_target?(o) FILTER_OPTION.each do |k| return true if !o[k].nil? && !o[k].empty? end false end
format(data, f)
click to toggle source
data convert
@param data [Hash] @param f [String] format @return String
# File lib/idcf/cli/lib/convert/helper.rb, line 19 def format(data, f) cls_load("Formatter::#{f.classify}Format").new.format(data) end
only_filter_fields?(o)
click to toggle source
only filter
@param o [Hash] @return Boolean
# File lib/idcf/cli/lib/convert/helper.rb, line 37 def only_filter_fields?(o) return false if o[:fields].nil? list = [] FILTER_OPTION.each do |k| list << k if o[k].present? end list.count == 1 end
Protected Instance Methods
cls_load(path)
click to toggle source
# File lib/idcf/cli/lib/convert/helper.rb, line 66 def cls_load(path) cls = "#{Idcf::Cli::Lib::Util::Name.namespace(self.class.to_s)}::#{path}" require cls.underscore cls.constantize end