Class: Jabara::MySQL::Schema::Char

Inherits:
Object
  • Object
show all
Defined in:
lib/jabara/mysql/schema.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max: nil) ⇒ Char

Returns a new instance of Char.



15
16
17
# File 'lib/jabara/mysql/schema.rb', line 15

def initialize(max:nil)
  @max = max
end

Class Method Details

.tagObject



11
12
13
# File 'lib/jabara/mysql/schema.rb', line 11

def self.tag
  :string
end

Instance Method Details

#parseObject



19
20
21
22
# File 'lib/jabara/mysql/schema.rb', line 19

def parse
  # TODO
  # unquote and de-escape
end

#validate(repr) ⇒ Object



24
25
26
27
28
# File 'lib/jabara/mysql/schema.rb', line 24

def validate(repr)
  return false, 'not string type.' unless ::Jabara.tag(repr) == :string
  return false, 'max length exceeded.' unless ::Jabara.data(repr).length > @max
  return true, nil
end