Class: Metro::Views::YAMLView
- Inherits:
-
Object
- Object
- Metro::Views::YAMLView
- Defined in:
- lib/metro/views/yaml_view.rb
Class Method Summary collapse
-
.default_extname ⇒ Object
The default extension to use when saving yaml files.
-
.default_extname=(value) ⇒ Object
Set the default extname.
-
.exists?(view_path) ⇒ Boolean
Determine if a view exists for this specified format.
-
.format ⇒ Object
The file type format of this view.
-
.parse(view_path) ⇒ Object
Parse the contents of the view given the name.
- .write(view_path, content) ⇒ Object
Class Method Details
.default_extname ⇒ Object
Returns the default extension to use when saving yaml files.
48 49 50 |
# File 'lib/metro/views/yaml_view.rb', line 48 def self.default_extname @default_extname || ".yaml" end |
.default_extname=(value) ⇒ Object
Set the default extname
59 60 61 |
# File 'lib/metro/views/yaml_view.rb', line 59 def self.default_extname=(value) @default_extname = value end |
.exists?(view_path) ⇒ Boolean
Determine if a view exists for this specified format
14 15 16 |
# File 'lib/metro/views/yaml_view.rb', line 14 def self.exists?(view_path) yaml_view_paths(view_path).find { |view_path| File.exists? view_path } end |
.format ⇒ Object
Returns the file type format of this view.
31 32 33 |
# File 'lib/metro/views/yaml_view.rb', line 31 def self.format :yaml end |
.parse(view_path) ⇒ Object
Parse the contents of the view given the name.
24 25 26 |
# File 'lib/metro/views/yaml_view.rb', line 24 def self.parse(view_path) YAML.load(File.read(yaml_view_path(view_path))) or { } end |
.write(view_path, content) ⇒ Object
39 40 41 42 43 |
# File 'lib/metro/views/yaml_view.rb', line 39 def self.write(view_path,content) filename = write_filepath(view_path) yaml_content = content.to_yaml File.write(filename,yaml_content) end |