Class: SqlMigrations::File
- Inherits:
-
Object
- Object
- SqlMigrations::File
- Defined in:
- lib/sql_migrations/file.rb
Overview
Class that represents script file
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#datetime ⇒ Object
readonly
Returns the value of attribute datetime.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #content ⇒ Object
-
#initialize(path, database, type) ⇒ File
constructor
A new instance of File.
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(path, database, type) ⇒ File
Returns a new instance of File.
7 8 9 10 11 12 13 14 15 |
# File 'lib/sql_migrations/file.rb', line 7 def initialize(path, database, type) @path = path @database = database @type = type.to_s @file, @base, @parent = elements(path) @date, @time, @name = match(@file) if @file @datetime = (@date.to_s + @time.to_s).to_i end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
5 6 7 |
# File 'lib/sql_migrations/file.rb', line 5 def database @database end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
5 6 7 |
# File 'lib/sql_migrations/file.rb', line 5 def date @date end |
#datetime ⇒ Object (readonly)
Returns the value of attribute datetime.
5 6 7 |
# File 'lib/sql_migrations/file.rb', line 5 def datetime @datetime end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/sql_migrations/file.rb', line 5 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/sql_migrations/file.rb', line 5 def path @path end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
5 6 7 |
# File 'lib/sql_migrations/file.rb', line 5 def time @time end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/sql_migrations/file.rb', line 5 def type @type end |
Instance Method Details
#==(other) ⇒ Object
25 26 27 |
# File 'lib/sql_migrations/file.rb', line 25 def ==(other) datetime == other.datetime end |
#content ⇒ Object
21 22 23 |
# File 'lib/sql_migrations/file.rb', line 21 def content ::File.read(@path) end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/sql_migrations/file.rb', line 29 def to_s @file.to_s end |
#valid? ⇒ Boolean
17 18 19 |
# File 'lib/sql_migrations/file.rb', line 17 def valid? [@name, @time, @date, @database, directories?].all? end |