Module: Card::Set::Helpers

Included in:
Card::Set
Defined in:
lib/card/set/helpers.rb

Instance Method Summary collapse

Instance Method Details

#abstract_set?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/card/set/helpers.rb', line 23

def abstract_set?
  name =~ /^Card::Set::Abstract::/
end

#all_set?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/card/set/helpers.rb', line 27

def all_set?
  name =~ /^Card::Set::All::/
end

#num_set_parts(pattern_code) ⇒ Object

move to Set::Pattern?



17
18
19
20
21
# File 'lib/card/set/helpers.rb', line 17

def num_set_parts pattern_code
  return 1 if pattern_code == :abstract

  Pattern.find(pattern_code).anchor_parts_count
end

#shortnameObject



4
5
6
7
8
9
10
# File 'lib/card/set/helpers.rb', line 4

def shortname
  parts = name.split "::"
  first = 2 # shortname eliminates Card::Set
  pattern_code = parts[first].underscore.to_sym
  last = first + num_set_parts(pattern_code)
  parts[first..last].join "::"
end

#underscoreObject



12
13
14
# File 'lib/card/set/helpers.rb', line 12

def underscore
  shortname.tr(":", "_").underscore
end