module Cardname::Predicates

Public Instance Methods

compound?() click to toggle source

@return true if name has more than one part

# File lib/cardname/predicates.rb, line 9
def compound?
  !simple?
end
Also aliased as: junction?
end_with_parts?(*suffix)
Alias for: ends_with_parts?
ends_with_parts?(*suffix) click to toggle source

@return true if name ends with the same parts as `prefix`

# File lib/cardname/predicates.rb, line 30
def ends_with_parts? *suffix
  end_name = suffix.to_name
  end_name == self[-end_name.num_parts..-1]
end
Also aliased as: end_with_parts?
include?(subname) click to toggle source

@return true if name has a chain of parts that equals `subname`

# File lib/cardname/predicates.rb, line 37
def include? subname
  subkey = subname.to_name.key
  key =~ /(^|#{JOINT_RE})#{Regexp.quote subkey}($|#{JOINT_RE})/
end
junction?()
Alias for: compound?
simple()
Alias for: simple?
simple?() click to toggle source
# File lib/cardname/predicates.rb, line 3
def simple?
  @simple.nil? ? (@simple = parts.size <= 1) : @simple
end
Also aliased as: simple
start_with_parts?(*prefix)
Alias for: starts_with_parts?
starts_with_parts?(*prefix) click to toggle source

@return true if name starts with the same parts as `prefix`

# File lib/cardname/predicates.rb, line 23
def starts_with_parts? *prefix
  start_name = prefix.to_name
  start_name == self[0, start_name.num_parts]
end
Also aliased as: start_with_parts?
valid?() click to toggle source
# File lib/cardname/predicates.rb, line 14
def valid?
  return true if self.class.nothing_banned?

  !parts.find do |pt|
    pt.match self.class.banned_re
  end
end