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.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/razor/cli/document.rb', line 7

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.



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

def format_view
  @format_view
end

#itemsObject (readonly)

Returns the value of attribute items.



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

def items
  @items
end

#original_itemsObject (readonly)

Returns the value of attribute original_items.



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

def original_items
  @original_items
end

#specObject (readonly)

Returns the value of attribute spec.



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

def spec
  @spec
end

Instance Method Details

#is_list?Boolean

Returns:

  • (Boolean)


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

def is_list?
  @type == :list
end