Top Level Namespace

Defined Under Namespace

Modules: EnumStateMachine

Instance Method Summary collapse

Instance Method Details

#initObject

Define where state machine descriptions will be rendered



4
5
6
7
# File 'lib/enum_state_machine/yard/templates/default/class/html/setup.rb', line 4

def init
  super
  sections.place(:state_machine_details).before(:children)
end

#state_machine_detailsObject

Renders state machine details in the main content of the class’s documentation



10
11
12
# File 'lib/enum_state_machine/yard/templates/default/class/html/setup.rb', line 10

def state_machine_details
  erb(:state_machines) if state_machines
end

#state_machine_image_path(machine) ⇒ Object

Generates the image path for the given machine’s visualization



26
27
28
29
30
# File 'lib/enum_state_machine/yard/templates/default/class/html/setup.rb', line 26

def state_machine_image_path(machine)
  base_path = File.dirname(serializer.serialized_path(object))
  image_name = "#{object.name}_#{machine[:name]}"
  "#{File.join(base_path, image_name)}.png"
end

#state_machinesObject

Gets a list of state machines prased for this class



15
16
17
18
19
20
21
22
23
# File 'lib/enum_state_machine/yard/templates/default/class/html/setup.rb', line 15

def state_machines
  @state_machines ||= begin
    if state_machines = object['state_machines']
      state_machines.each do |name, machine|
        serializer.serialize(state_machine_image_path(machine), machine[:image]) if machine[:image]
      end
    end
  end
end