Module: Playbook::Truncate

Included in:
KitBase
Defined in:
lib/playbook/truncate.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
# File 'lib/playbook/truncate.rb', line 5

def self.included(base)
  base.prop :truncate
end

Instance Method Details

#truncate_optionsObject



19
20
21
22
23
# File 'lib/playbook/truncate.rb', line 19

def truncate_options
  {
    truncate: "truncate",
  }
end

#truncate_propsObject



9
10
11
12
13
14
15
16
17
# File 'lib/playbook/truncate.rb', line 9

def truncate_props
  selected_props = truncate_options.keys.select { |sk| try(sk) }
  return nil unless selected_props.present?

  selected_props.map do |k|
    truncate_value = send(k)
    "truncate_#{truncate_value}" if truncate_values.include? truncate_value
  end.compact.join(" ")
end

#truncate_valuesObject



25
26
27
# File 'lib/playbook/truncate.rb', line 25

def truncate_values
  %w[1 2 3 4 5]
end