Class: PgTypes::FileVersion

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileVersion

Returns a new instance of FileVersion.



7
8
9
10
11
# File 'lib/pg_types/file_version.rb', line 7

def initialize(path)
  @path = Pathname.new(path)
  @name = @path.basename.to_s.sub(/_v\d+\.sql$/, "")
  @version = extract_version
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/pg_types/file_version.rb', line 5

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/pg_types/file_version.rb', line 5

def path
  @path
end

#versionObject (readonly)

Returns the value of attribute version.



5
6
7
# File 'lib/pg_types/file_version.rb', line 5

def version
  @version
end

Instance Method Details

#sql_definitionObject



13
14
15
# File 'lib/pg_types/file_version.rb', line 13

def sql_definition
  File.read(path).strip
end