Sha256: 611fb27f8d3c467585a64aea31fbae0f70205b4f7eb687e80f2c44d298b71ac2

Contents?: true

Size: 360 Bytes

Versions: 2

Compression:

Stored size: 360 Bytes

Contents

#
# you can retrieve all fattrs as a list, or a hash with values included
#
  require 'fattr'

  class C
    fattr(:a)
    fattr(:b){ a.to_f }
  end

  o = C.new

  o.fattr(:c)
  o.fattr(:d){ self.c.upcase }

  o.a = 42
  o.c = 'forty-two' 

  p o.fattrs.to_hash #=> {"a"=>42, "b"=>42.0, "c"=>"forty-two", "d"=>"FORTY-TWO"}
  p o.fattrs         #=> ["c", "d"]

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fattr-2.4.0 samples/i.rb
fattr-2.3.0 samples/i.rb