Class: DBRotator::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/db_rotator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, schema_regex) ⇒ Schema

Returns a new instance of Schema.



146
147
148
149
# File 'lib/db_rotator.rb', line 146

def initialize(name, schema_regex)
  @name = name
  @schema_regex = schema_regex
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



144
145
146
# File 'lib/db_rotator.rb', line 144

def name
  @name
end

Instance Method Details

#to_dateObject



151
152
153
154
155
156
# File 'lib/db_rotator.rb', line 151

def to_date
  Date.strptime(
    name.match(@schema_regex)[1],
    TIME_FORMAT
  )
end