Class: Card::Set::All::NestEditor::NestParser

Inherits:
Object
  • Object
show all
Defined in:
tmpsets/set/mod023-edit/all/nest_editor/nest_parser.rb

Overview

from a nest syntax string

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nest_string, _default_view, default_item_view) ⇒ NestParser

Returns a new instance of NestParser.



26
27
28
29
30
31
32
33
# File 'tmpsets/set/mod023-edit/all/nest_editor/nest_parser.rb', line 26

def initialize nest_string, _default_view, default_item_view
  @raw = nest_string
  @default_item_view = default_item_view
  nest = Card::Content::Chunk::Nest.new nest_string, nil
  init_name nest.name
  extract_item_options nest.options
  @options = extract_options nest.options
end

Instance Attribute Details

#item_optionsObject (readonly)

Returns the value of attribute item_options.



12
13
14
# File 'tmpsets/set/mod023-edit/all/nest_editor/nest_parser.rb', line 12

def item_options
  @item_options
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'tmpsets/set/mod023-edit/all/nest_editor/nest_parser.rb', line 12

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



12
13
14
# File 'tmpsets/set/mod023-edit/all/nest_editor/nest_parser.rb', line 12

def options
  @options
end

#rawObject (readonly)

Returns the value of attribute raw.



12
13
14
# File 'tmpsets/set/mod023-edit/all/nest_editor/nest_parser.rb', line 12

def raw
  @raw
end

Class Method Details

.new(nest_string, default_view, default_item_view) ⇒ Object



14
15
16
17
18
19
20
# File 'tmpsets/set/mod023-edit/all/nest_editor/nest_parser.rb', line 14

def self.new nest_string, default_view, default_item_view
  return super if nest_string.is_a? String

  OpenStruct.new(name: "", field?: true,
                 options: [[:view, default_view]], item_options: [],
                 raw: "{{+|view: #{default_view}}}")
end

Instance Method Details

#field?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'tmpsets/set/mod023-edit/all/nest_editor/nest_parser.rb', line 22

def field?
  @field
end