Class: Kaui::TagDefinition

Inherits:
KillBillClient::Model::TagDefinition
  • Object
show all
Defined in:
app/models/kaui/tag_definition.rb

Instance Method Summary collapse

Instance Method Details

#<=>(tag_definition) ⇒ Object



42
43
44
45
46
47
# File 'app/models/kaui/tag_definition.rb', line 42

def <=>(tag_definition)
  # System tags last
  return 1 if is_system_tag? and !tag_definition.is_system_tag?
  return -1 if !is_system_tag? and tag_definition.is_system_tag?
  name <=> tag_definition.name
end

#is_system_tag?Boolean

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/models/kaui/tag_definition.rb', line 28

def is_system_tag?
  return false unless id.present?
  last_group = id.split('-')[4]

  is_system_tag = true
  last_group.split(//).each_with_index do |c, i|
    unless (c == '0' and i < 11) or (c.to_i > 0 and i == 11)
      is_system_tag = false
      break
    end
  end
  is_system_tag
end