Class: MaterialClassDecorator

Inherits:
SimpleDecorator::Base show all
Defined in:
app/decorators/material_class_decorator.rb

Instance Method Summary collapse

Methods inherited from SimpleDecorator::Base

#component

Methods included from SimpleDecorator::RailsHelpers

#try

Instance Method Details

#child_maskObject



13
14
15
# File 'app/decorators/material_class_decorator.rb', line 13

def child_mask
  '9' * child_mask_size
end

#filled_masked_number(append_dot = false) ⇒ Object



17
18
19
20
21
22
23
# File 'app/decorators/material_class_decorator.rb', line 17

def filled_masked_number(append_dot = false)
  if append_dot && levels > class_number_level && masked_number.present?
    filled_masked_number_without_end_dot + '.'
  else
    filled_masked_number_without_end_dot
  end
end

#last_level_class_numberObject



33
34
35
# File 'app/decorators/material_class_decorator.rb', line 33

def last_level_class_number
  splitted_masked_number_filled[-1].to_s
end

#masked_to_sObject



4
5
6
# File 'app/decorators/material_class_decorator.rb', line 4

def masked_to_s
  "#{filled_masked_number} - #{description}"
end

#persisted_masked_to_sObject



8
9
10
11
# File 'app/decorators/material_class_decorator.rb', line 8

def persisted_masked_to_s
  return unless parent && persisted_parent_masked_number
  "#{persisted_parent_masked_number} - #{parent.description}"
end

#persisted_parent_masked_number(append_dot = false) ⇒ Object



25
26
27
28
29
30
31
# File 'app/decorators/material_class_decorator.rb', line 25

def persisted_parent_masked_number(append_dot = false)
  data = filled_masked_number.split('.')[0..-2].join('.')

  data += '.' if append_dot && class_number_level > 1

  data
end