Class: JunglePath::Gen::SchemaTree::MatchColumns
- Inherits:
-
Object
- Object
- JunglePath::Gen::SchemaTree::MatchColumns
- Defined in:
- lib/jungle_path/gen/schema_tree/match_columns.rb
Instance Attribute Summary collapse
-
#is_nil ⇒ Object
readonly
Returns the value of attribute is_nil.
Instance Method Summary collapse
-
#initialize(columns) ⇒ MatchColumns
constructor
A new instance of MatchColumns.
- #matched?(column_name) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(columns) ⇒ MatchColumns
Returns a new instance of MatchColumns.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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 |
Instance Attribute Details
#is_nil ⇒ Object (readonly)
Returns the value of attribute is_nil.
5 6 7 |
# File 'lib/jungle_path/gen/schema_tree/match_columns.rb', line 5 def is_nil @is_nil end |
Instance Method Details
#matched?(column_name) ⇒ Boolean
39 40 41 42 43 44 45 46 |
# 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 ⇒ Object
48 49 50 |
# File 'lib/jungle_path/gen/schema_tree/match_columns.rb', line 48 def to_s "is_nil: #{@is_nil}, hash: #{@hash}, regexes: #{@regexes}." end |