Module: DevTools

Extended by:
ArgsUpdate
Defined in:
tomes/conjurations/dev_tools/dev_tools.rb

Overview

A module containing some methods and variables to aid development. You can constantly update it like the classes that use ArgsUpdate or you can call it as needed. If you opt for the latter you will need to provide args as the final argument in each method.

Class Method Summary collapse

Methods included from ArgsUpdate

update

Class Method Details

.render_label_primitives(label_hashes, args = self.args) ⇒ Void

A method for rendering a list of label primitives.

Parameters:

  • label_hashes (Array<Hashes>)
  • args (Args) (defaults to: self.args)

Returns:

  • (Void)


62
63
64
65
66
# File 'tomes/conjurations/dev_tools/dev_tools.rb', line 62

def render_label_primitives(label_hashes, args = self.args)
  return if text_hashes.nil?

  args.outputs.labels << label_hashes.each
end

.render_object_borders(object_list, args = self.args) ⇒ Void Also known as: render_hitboxes

Generates an array of rect hashes from the given list and passes that into ‘args.outputs.primitives`.

Parameters:

  • object_list (Array<Objects>)

    These objects must respond to #rect.

  • args (Args) (defaults to: self.args)

Returns:

  • (Void)


53
54
55
# File 'tomes/conjurations/dev_tools/dev_tools.rb', line 53

def render_object_borders(object_list, args = self.args)
  args.outputs.borders << object_list.map(&:rect)
end

.render_objects(object_list, args = self.args) ⇒ Void

Generates an array of primitive hashes from the given list and passes that into ‘args.outputs.primitives`.

Parameters:

  • object_list (Array<Objects>)

    These objects must respond to #primitives.

  • args (Args) (defaults to: self.args)

Returns:

  • (Void)


37
38
39
# File 'tomes/conjurations/dev_tools/dev_tools.rb', line 37

def render_objects(object_list, args = self.args)
  args.outputs.primitives << object_list.map(&:primitives)
end

.render_primitives(primitive_hashes, args = self.args) ⇒ Void

Passes the given array of primitive hashes into ‘args.outputs.primitives`.

Parameters:

  • primitive_hashes (Array<Hashes>)
  • args (Args) (defaults to: self.args)

Returns:

  • (Void)


45
46
47
# File 'tomes/conjurations/dev_tools/dev_tools.rb', line 45

def render_primitives(primitive_hashes, args = self.args)
  args.outputs.primitives << primitive_hashes
end

.render_string_array(location, text_array, args = self.args) ⇒ Void Also known as: list

Note:

This method does not recognize escape characters like “n”.

Generates an array of hashes for each string in the given list and passes that into ‘args.outputs.labels`. Renders strings from top to bottom. Starts from the given location and grows downward.

Parameters:

  • location (Array<Integer, Integer>)

    The top-left corner of the first line of text.

  • text_array (Array<Strings>)
  • args (Args) (defaults to: self.args)

Returns:

  • (Void)


19
20
21
22
23
24
25
26
27
28
29
30
# File 'tomes/conjurations/dev_tools/dev_tools.rb', line 19

def render_string_array(location, text_array, args = self.args)
  return if text_array.nil?

  args.outputs.labels <<
    text_array.map_with_index do |e, i|
      {
        x: location[0],
        y: location[1] - (i * 25),
        text: e
      }
    end
end