Class: Gendered::NameList
- Inherits:
-
Object
- Object
- Gendered::NameList
- Includes:
- Enumerable
- Defined in:
- lib/gendered/name_list.rb
Instance Attribute Summary collapse
-
#names ⇒ Object
readonly
Returns the value of attribute names.
Instance Method Summary collapse
- #[](value) ⇒ Object
- #each(&block) ⇒ Object
- #guess! ⇒ Object
-
#initialize(values, options = {}) ⇒ NameList
constructor
A new instance of NameList.
Constructor Details
#initialize(values, options = {}) ⇒ NameList
Returns a new instance of NameList.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/gendered/name_list.rb', line 7 def initialize(values, = {}) @names = Array(values).collect do |value| case value when String then Name.new(value) when Name then value end end @options = || {} end |
Instance Attribute Details
#names ⇒ Object (readonly)
Returns the value of attribute names.
5 6 7 |
# File 'lib/gendered/name_list.rb', line 5 def names @names end |
Instance Method Details
#[](value) ⇒ Object
31 32 33 34 35 |
# File 'lib/gendered/name_list.rb', line 31 def [](value) names.find do |name| name.value == value end end |
#each(&block) ⇒ Object
25 26 27 28 29 |
# File 'lib/gendered/name_list.rb', line 25 def each(&block) names.each do |name| block.call name end end |