Class: GryphonNest::LayoutFile

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

Overview

Wrapper class for operations performed on the layout.yaml file

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ LayoutFile

Returns a new instance of LayoutFile.

Parameters:

  • path (Pathname)


7
8
9
10
11
# File 'lib/gryphon_nest/layout_file.rb', line 7

def initialize(path)
  @path = path
  @content = nil
  @last_mtime = Time.now
end

Instance Method Details

#content ⇒ String

Returns:

  • (String)


24
25
26
27
28
29
30
31
32
33
# File 'lib/gryphon_nest/layout_file.rb', line 24

def content
  mod_time = mtime

  if @content.nil? || mod_time > @last_mtime
    @content = @path.read
    @last_mtime = mod_time
  end

  @content
end

#exist? ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/gryphon_nest/layout_file.rb', line 14

def exist?
  @path.exist?
end

#mtime ⇒ Time

Returns:

  • (Time)


19
20
21
# File 'lib/gryphon_nest/layout_file.rb', line 19

def mtime
  @path.mtime
end