Class: Mate::TmProperties

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

Defined Under Namespace

Classes: Ignores

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ TmProperties

Returns a new instance of TmProperties.



6
7
8
9
# File 'lib/mate/tm_properties.rb', line 6

def initialize(dir)
  @dir = Pathname(dir).expand_path
  @file = @dir + '.tm_properties'
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



5
6
7
# File 'lib/mate/tm_properties.rb', line 5

def dir
  @dir
end

#fileObject (readonly)

Returns the value of attribute file.



5
6
7
# File 'lib/mate/tm_properties.rb', line 5

def file
  @file
end

Instance Method Details

#saveObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mate/tm_properties.rb', line 11

def save
  ignores = Ignores.new(dir)

  lines = if file.exist?
    file.readlines.reject do |line|
      line =~ Ignores::GENERATED_R
    end
  else
    []
  end

  @file.open('w') do |f|
    f.puts ignores.lines
    f.puts lines
  end
end