Class: Razor::CLI::Document
- Inherits:
-
Object
- Object
- Razor::CLI::Document
- Extended by:
- Forwardable
- Defined in:
- lib/razor/cli/document.rb
Instance Attribute Summary collapse
-
#format_view ⇒ Object
readonly
Returns the value of attribute format_view.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#original_items ⇒ Object
readonly
Returns the value of attribute original_items.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Instance Method Summary collapse
-
#initialize(doc, format_type) ⇒ Document
constructor
A new instance of Document.
- #is_list? ⇒ Boolean
Constructor Details
#initialize(doc, format_type) ⇒ Document
Returns a new instance of Document.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/razor/cli/document.rb', line 8 def initialize(doc, format_type) if doc['spec'].is_a?(Array) @spec, @remaining_navigation = doc['spec'] else @spec = doc['spec'] end @command = doc['command'] if doc.has_key?('items') @type = :list else @type = :single end @items = doc['items'] || Array[doc] @format_view = Razor::CLI::Views.find_formatting(@spec, format_type, @remaining_navigation) # Untransformed and unordered for displaying nested views. @original_items = @items @items = hide_or_transform_elements!(items, format_view) end |
Instance Attribute Details
#format_view ⇒ Object (readonly)
Returns the value of attribute format_view.
7 8 9 |
# File 'lib/razor/cli/document.rb', line 7 def format_view @format_view end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
7 8 9 |
# File 'lib/razor/cli/document.rb', line 7 def items @items end |
#original_items ⇒ Object (readonly)
Returns the value of attribute original_items.
7 8 9 |
# File 'lib/razor/cli/document.rb', line 7 def original_items @original_items end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
7 8 9 |
# File 'lib/razor/cli/document.rb', line 7 def spec @spec end |
Instance Method Details
#is_list? ⇒ Boolean
28 29 30 |
# File 'lib/razor/cli/document.rb', line 28 def is_list? @type == :list end |