Class: Flydata::PluginSupport::SourcePositionFile

Inherits:
Object
  • Object
show all
Defined in:
lib/flydata/plugin_support/source_position_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SourcePositionFile

Returns a new instance of SourcePositionFile.



7
8
9
# File 'lib/flydata/plugin_support/source_position_file.rb', line 7

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/flydata/plugin_support/source_position_file.rb', line 5

def path
  @path
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/flydata/plugin_support/source_position_file.rb', line 11

def exists?
  File.exists?(@path)
end

#posObject



19
20
21
22
23
24
25
# File 'lib/flydata/plugin_support/source_position_file.rb', line 19

def pos
  if exists?
    self.class::SOURCE_POS_CLASS.load(read)
  else
    nil
  end
end

#readObject



15
16
17
# File 'lib/flydata/plugin_support/source_position_file.rb', line 15

def read
  File.open(@path) {|f| f.read }
end

#save(*args) ⇒ Object



27
28
29
30
31
# File 'lib/flydata/plugin_support/source_position_file.rb', line 27

def save(*args)
  c = self.class::SOURCE_POS_CLASS.new(*args)
  File.open(@path, 'w') {|f| f.write(c.to_s) }
  c
end