class JunglePath::Gen::SchemaTree::MatchColumns
Attributes
is_nil[R]
Public Class Methods
new(columns)
click to toggle source
# File lib/jungle_path/gen/schema_tree/match_columns.rb, line 6 def initialize columns @is_nil = false @hash = {} @regexes = [] if columns if columns.class == Symbol @hash[columns] = true elsif columns.class == String @hash[columns.to_sym] = true elsif columns.class == Regexp @regexes << columns elsif columns.class == Array and columns.length > 0 columns.each do |col| if col.class == Symbol @hash[col] = true elsif columns.class == String @hash[col.to_sym] = true elsif col.class == Regexp @regexes << col else throw "Invalid type for col array item: #{col.class}, value: #{col}." end end elsif columns.class == Array @is_nil = true else throw "Invalid type for columns parameter: #{columns.class}, value: #{columns}." end else @is_nil = true end end
Public Instance Methods
matched?(column_name)
click to toggle source
# File lib/jungle_path/gen/schema_tree/match_columns.rb, line 39 def matched? column_name return true if @is_nil return true if @hash[column_name.to_sym] @regexes.each do |regx| return true if regx =~ column_name.to_s end false end
to_s()
click to toggle source
# File lib/jungle_path/gen/schema_tree/match_columns.rb, line 48 def to_s "is_nil: #{@is_nil}, hash: #{@hash}, regexes: #{@regexes}." end