Class: Cardname
- Extended by:
- ClassMethods
- Includes:
- Contextual, Fields, Manipulate, Parts, Pieces, Predicates, Variants
- Defined in:
- cardname/lib/cardname.rb,
cardname/lib/cardname/parts.rb,
cardname/lib/cardname/fields.rb,
cardname/lib/cardname/pieces.rb,
cardname/lib/cardname/variants.rb,
cardname/lib/cardname/contextual.rb,
cardname/lib/cardname/manipulate.rb,
cardname/lib/cardname/predicates.rb,
cardname/lib/cardname/class_methods.rb
Overview
The Cardname class generalizes the core naming concepts of Decko/Card. The most central of these is the idea that compound names can be formed by combining simple names.
Direct Known Subclasses
Defined Under Namespace
Modules: ClassMethods, Contextual, Fields, Manipulate, Parts, Pieces, Predicates, Variants
Constant Summary collapse
- OK4KEY_RE =
'\p{Word}\*'
- JOINT_RE =
Regexp.escape joint
Constants included from Contextual
Instance Attribute Summary collapse
-
#key ⇒ String
readonly
the key defines the namespace.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
test for same key.
-
#[](*args) ⇒ Cardname
cardname based on part index.
-
#initialize(str) ⇒ Cardname
constructor
A new instance of Cardname.
-
#num_parts ⇒ Integer
-
#s ⇒ String
(also: #to_s, #to_str)
simple string version of name.
-
#to_name ⇒ Cardname
-
#to_sym ⇒ Symbol
Methods included from ClassMethods
banned_re, cache, new, nothing_banned?, reset, split_parts
Methods included from Fields
#field, #field_name, #field_of?, #field_only?, #relative_field_name
Methods included from Manipulate
#<<, #[]=, #prepend_joint, #sub_in, #swap
Methods included from Predicates
#compound?, #ends_with_parts?, #include?, #simple?, #starts_with_joint?, #starts_with_parts?, #valid?
Methods included from Contextual
#absolute, #absolute?, #absolute_name, #child_of?, #from, #name_from, #nth_left_name, #relative?, #simple_relative?
Methods included from Variants
#decoded, #fully_stripped, #safe_key, #stripped, #url_key
Methods included from Pieces
#ancestor_pieces, #ancestors, #piece_names, #pieces
Methods included from Parts
#left, #left_key, #left_name, #parent_keys, #parent_names, #parents, #part_keys, #part_names, #parts, #right, #right_key, #right_name, #tag, #tag_key, #tag_name, #trunk, #trunk_key, #trunk_name
Constructor Details
#initialize(str) ⇒ Cardname
Returns a new instance of Cardname.
44 45 46 47 48 49 50 51 52 |
# File 'cardname/lib/cardname.rb', line 44 def initialize str super str strip! encode! "UTF-8" part_names # populates @part_names and @simple decoded # populates @decoded key # populates and freezes @key freeze end |
Instance Attribute Details
#key ⇒ String (readonly)
the key defines the namespace
42 43 44 |
# File 'cardname/lib/cardname.rb', line 42 def key @key end |
Instance Method Details
#==(other) ⇒ Boolean
test for same key
80 81 82 83 84 85 86 87 |
# File 'cardname/lib/cardname.rb', line 80 def == other key == case when other.respond_to?(:key) then other.key when other.respond_to?(:to_name) then other.to_name.key else other.to_s.to_name.key end end |
#[](*args) ⇒ Cardname
cardname based on part index
91 92 93 |
# File 'cardname/lib/cardname.rb', line 91 def [] *args self.class.new part_names[*args] end |
#num_parts ⇒ Integer
97 98 99 |
# File 'cardname/lib/cardname.rb', line 97 def num_parts parts.length end |
#s ⇒ String Also known as: to_s, to_str
simple string version of name
56 57 58 |
# File 'cardname/lib/cardname.rb', line 56 def s String.new self end |
#to_sym ⇒ Symbol
68 69 70 |
# File 'cardname/lib/cardname.rb', line 68 def to_sym s.to_sym end |