Class: Govuk::DummyContentStore::ExampleContentItem
- Inherits:
-
Object
- Object
- Govuk::DummyContentStore::ExampleContentItem
- Defined in:
- lib/govuk/dummy_content_store/example_content_item.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #base_path ⇒ Object
- #data ⇒ Object
- #filename ⇒ Object
- #format ⇒ Object
-
#initialize(path) ⇒ ExampleContentItem
constructor
A new instance of ExampleContentItem.
- #raw_data ⇒ Object
- #title ⇒ Object
- #view_url ⇒ Object
Constructor Details
#initialize(path) ⇒ ExampleContentItem
Returns a new instance of ExampleContentItem.
8 9 10 |
# File 'lib/govuk/dummy_content_store/example_content_item.rb', line 8 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/govuk/dummy_content_store/example_content_item.rb', line 6 def path @path end |
Instance Method Details
#base_path ⇒ Object
16 17 18 |
# File 'lib/govuk/dummy_content_store/example_content_item.rb', line 16 def base_path data["base_path"] end |
#data ⇒ Object
32 33 34 |
# File 'lib/govuk/dummy_content_store/example_content_item.rb', line 32 def data JSON.parse(raw_data) end |
#filename ⇒ Object
12 13 14 |
# File 'lib/govuk/dummy_content_store/example_content_item.rb', line 12 def filename File.basename(path) end |
#format ⇒ Object
20 21 22 |
# File 'lib/govuk/dummy_content_store/example_content_item.rb', line 20 def format data["format"] end |
#raw_data ⇒ Object
36 37 38 |
# File 'lib/govuk/dummy_content_store/example_content_item.rb', line 36 def raw_data File.read(path, encoding: "UTF-8") end |
#title ⇒ Object
24 25 26 |
# File 'lib/govuk/dummy_content_store/example_content_item.rb', line 24 def title data["title"] end |
#view_url ⇒ Object
28 29 30 |
# File 'lib/govuk/dummy_content_store/example_content_item.rb', line 28 def view_url "/content#{base_path}" end |