Class: DraftjsExporter::EntityState

Inherits:
Object
  • Object
show all
Defined in:
lib/draftjs_exporter/entity_state.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_element, entity_decorators, entity_map) ⇒ EntityState

Returns a new instance of EntityState.



8
9
10
11
12
# File 'lib/draftjs_exporter/entity_state.rb', line 8

def initialize(root_element, entity_decorators, entity_map)
  @entity_decorators = entity_decorators
  @entity_map = entity_map
  @entity_stack = [[Entities::Null.new.call(root_element, nil), nil]]
end

Instance Attribute Details

#entity_decoratorsObject (readonly)

Returns the value of attribute entity_decorators.



6
7
8
# File 'lib/draftjs_exporter/entity_state.rb', line 6

def entity_decorators
  @entity_decorators
end

#entity_mapObject (readonly)

Returns the value of attribute entity_map.



6
7
8
# File 'lib/draftjs_exporter/entity_state.rb', line 6

def entity_map
  @entity_map
end

#entity_stackObject (readonly)

Returns the value of attribute entity_stack.



6
7
8
# File 'lib/draftjs_exporter/entity_state.rb', line 6

def entity_stack
  @entity_stack
end

#root_elementObject (readonly)

Returns the value of attribute root_element.



6
7
8
# File 'lib/draftjs_exporter/entity_state.rb', line 6

def root_element
  @root_element
end

Instance Method Details

#apply(command) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/draftjs_exporter/entity_state.rb', line 14

def apply(command)
  case command.name
  when :start_entity
    start_command(command)
  when :stop_entity
    stop_command(command)
  end
end

#current_parentObject



23
24
25
26
# File 'lib/draftjs_exporter/entity_state.rb', line 23

def current_parent
  element, _data = entity_stack.last
  element
end