summaryrefslogtreecommitdiffhomepage
path: root/deprecated/helpers/01_component.rb
blob: 12cce091f4c4cb9aeba51dd588c3c0e7640d0e4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# frozen_string_literal: true

class FelFlame
  class Helper
    #  # Unused:
    #     class Level < FelFlame::Helper::ComponentManager
    #       class <<self
    #         def data
    #           @data ||= { add: [], remove: [], grid: FelFlame::Helper::Array2D.new }
    #         end
    #
    #         def add(entity_id)
    #           super
    #           data[:add].push entity_id
    #         end
    #
    #         def remove(entity_id)
    #           data[:remove].push entity_id
    #           super
    #         end
    #       end
    #     end
    #     class Array2D < Array
    #       def [](val)
    #         unless val.nil?
    #           return self[val] = [] if super.nil?
    #         end
    #         super
    #       end
    #     end
    #     class ArrayOfHashes < Array
    #       def [](val)
    #         unless val.nil?
    #           return self[val] = {} if super.nil?
    #         end
    #         super
    #       end
    #     end

    #     module ComponentHelper
    #       class <<self
    #         def up? char
    #           char == char.upcase
    #         end
    #
    #         def down? char
    #           char == char.downcase
    #         end
    #
    #         def underscore(input)
    #           output = input[0].downcase
    #           (1...(input.length - 1)).each do |iter|
    #             if down?(input[iter]) && up?(input[iter + 1])
    #               output += "#{input[iter].downcase}_"
    #             elsif up?(input[iter - 1]) && up?(input[iter]) && down?(input[iter + 1])
    #               output += "_#{input[iter].downcase}"
    #             else
    #               output += input[iter].downcase
    #             end
    #           end
    #           output += input[-1].downcase unless input.length == 1
    #           output
    #         end
    #       end
    #     end
  end
end