Class: PrettyFeed::PfTf

Inherits:
Module
  • Object
show all
Defined in:
lib/pretty_feed/pf_tf.rb

Overview

Pretty Feed Truthy Falsey

Usage in a rake task, for example:

namespace :scrub do
  task :blurb => :environment do |_t, args|
    include PrettyFeed::PfTf.new(truthy: 'green', falsey: 'blue')
    pftf("this will be green", true)
    # => "this will be green" # but in green
    pftf("this will be blue", false)
    # => "this will be blue" # but in blue
  end
end

Instance Method Summary collapse

Constructor Details

#initialize(truthy: "green", falsey: "red") ⇒ PfTf

Returns a new instance of PfTf.



19
20
21
22
23
24
# File 'lib/pretty_feed/pf_tf.rb', line 19

def initialize(truthy: "green", falsey: "red")
  # Ruby's Module initializer doesn't take any arguments
  super()
  @truthy = truthy
  @falsey = falsey
end

Instance Method Details

#included(base) ⇒ Object



26
27
28
29
# File 'lib/pretty_feed/pf_tf.rb', line 26

def included(base)
  modulizer = Modulizer.to_mod(truthy: @truthy, falsey: @falsey)
  base.send(:prepend, modulizer)
end