Sha256: 8af6cd206a78acc7f89077d84cdd5b589926435214513fa28894e3de20384e81
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 KB
Contents
class Card class Name # Name-based "Fields" are compound names in which the right name is treated # as an attribute of the left. (Eg MyName+address) # # "Traits" are the subset of fields in which the right name corresponds to a # card with a codename module FieldsAndTraits # @return [String] def field tag_name field_name(tag_name).s end # @return [Card::Name] def field_name tag tag = tag.to_s[1..-1] if !tag.is_a?(Symbol) && tag.to_s[0] == "+" [self, tag].to_name end # @return [True/False] def field_of? context return false unless compound? if context.present? absolute_name(context).left_name.key == context.to_name.key else s.match?(/^\s*\+[^+]+$/) end end # name is relative name containing only the rightmost part # @return [True/False] def field_only? relative? && stripped.to_name.parts.reject(&:blank?).first == parts.last end def relative_field_name tag_name field_name(tag_name).name_from self end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
card-1.104.2 | lib/card/name/fields_and_traits.rb |
card-1.104.1 | lib/card/name/fields_and_traits.rb |
card-1.104.0 | lib/card/name/fields_and_traits.rb |