Class: Gryphon::LayoutFile

Inherits:
Object
  • Object
show all
Defined in:
lib/gryphon/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/layout_file.rb', line 7

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

Instance Method Details

#contentString

Returns:

  • (String)


20
21
22
23
24
25
26
27
28
29
# File 'lib/gryphon/layout_file.rb', line 20

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
# File 'lib/gryphon/layout_file.rb', line 14

def exist? = @path.exist?

#mtimeTime

Returns:

  • (Time)


17
# File 'lib/gryphon/layout_file.rb', line 17

def mtime = @path.mtime