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