Class: HtmlMockup::Mockupfile
- Inherits:
-
Object
- Object
- HtmlMockup::Mockupfile
- Defined in:
- lib/html_mockup/mockupfile.rb
Overview
Loader for mockupfile
Defined Under Namespace
Classes: Context
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(project) ⇒ Mockupfile
constructor
A new instance of Mockupfile.
-
#load ⇒ Object
Actually load the mockupfile.
-
#loaded? ⇒ Boolean
Wether or not the Mockupfile has been loaded.
- #release ⇒ Object
- #serve ⇒ Object (also: #server)
Constructor Details
#initialize(project) ⇒ Mockupfile
Returns a new instance of Mockupfile.
26 27 28 29 |
# File 'lib/html_mockup/mockupfile.rb', line 26 def initialize(project) @project = project @path = Pathname.new(project.path + "Mockupfile") end |
Instance Attribute Details
#path ⇒ Object
24 25 26 |
# File 'lib/html_mockup/mockupfile.rb', line 24 def path @path end |
#project ⇒ Object
24 25 26 |
# File 'lib/html_mockup/mockupfile.rb', line 24 def project @project end |
Instance Method Details
#load ⇒ Object
Actually load the mockupfile
32 33 34 35 36 37 38 39 |
# File 'lib/html_mockup/mockupfile.rb', line 32 def load if File.exist?(@path) && !self.loaded? @source = File.read(@path) context = Context.new(self) eval @source, context.binding, @path.to_s, 1 @loaded = true end end |
#loaded? ⇒ Boolean
Wether or not the Mockupfile has been loaded
42 43 44 |
# File 'lib/html_mockup/mockupfile.rb', line 42 def loaded? @loaded end |
#release ⇒ Object
46 47 48 49 50 51 |
# File 'lib/html_mockup/mockupfile.rb', line 46 def release if block_given? yield(self.project.release) end self.project.release end |
#serve ⇒ Object Also known as: server
53 54 55 56 57 58 |
# File 'lib/html_mockup/mockupfile.rb', line 53 def serve if block_given? yield(self.project.server) end self.project.server end |