Class: Razor::CLI::Document

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/razor/cli/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_viewObject (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

#itemsObject (readonly)

Returns the value of attribute items.



7
8
9
# File 'lib/razor/cli/document.rb', line 7

def items
  @items
end

#original_itemsObject (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

#specObject (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

Returns:

  • (Boolean)


28
29
30
# File 'lib/razor/cli/document.rb', line 28

def is_list?
  @type == :list
end