Sha256: bda11adb2e2c63ec56298d3f9a0ed15eeee0d7d4a004264ac26f1f3a469a96e1

Contents?: true

Size: 513 Bytes

Versions: 10

Compression:

Stored size: 513 Bytes

Contents

# encoding: utf-8
require 'attr_enumerable/attr_enumerable_helper'

# AttrEnumerable
module AttrEnumerable
  private
    def first_attr(attribute, method_name, *args, &block)
      col = collection
      return [] if col.empty?
      first_size = args.size == 0 ? nil : Integer(args.first)
      fail ArgumentError, "invalid attribute #{attribute}" unless include_attr?(col.first, attribute)
      attrs = col.map { |v|v.send(attribute) }
      first_size.nil? ? attrs.first : attrs.first(first_size)
    end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tbpgr_utils-0.0.151 lib/attr_enumerable/first_attr.rb
tbpgr_utils-0.0.150 lib/attr_enumerable/first_attr.rb
tbpgr_utils-0.0.149 lib/attr_enumerable/first_attr.rb
tbpgr_utils-0.0.148 lib/attr_enumerable/first_attr.rb
tbpgr_utils-0.0.147 lib/attr_enumerable/first_attr.rb
tbpgr_utils-0.0.146 lib/attr_enumerable/first_attr.rb
tbpgr_utils-0.0.145 lib/attr_enumerable/first_attr.rb
tbpgr_utils-0.0.144 lib/attr_enumerable/first_attr.rb
tbpgr_utils-0.0.143 lib/attr_enumerable/first_attr.rb
tbpgr_utils-0.0.142 lib/attr_enumerable/first_attr.rb