Project

prompter

0.0
No commit activity in last 3 years
No release in over 3 years
A few helpers to create colored, multistep and hierarchical wizards
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.1.2

Runtime

>= 0.1.1
>= 0.6.3
 Project Readme

Prompter¶ ↑

Makes your prompts easier to build and prettier to look.

Synopsis¶ ↑

require 'prompter'

Prompter.new(:prefix => '**  ') do |p|
  p.say_notice 'You can avoid to extend your class with Prompter::Methods'
end

# or

prompter = Prompter.new

# or you can also extend your modules with:

extend Prompter::Methods
self.prefix = '    '
say 'This part uses imported method from Prompter::Methods'

ask 'Type some input:' do |input|
  yes_no? "Do you want it or not?" do |yes|
    if yes
      say("#{input} is ok")
    else
      say_warning("#{input} may be dangerous")
    end
  end
end

# or

name = ask('write your name:')
yes? "are you sure?" { do_something_if_yes }

(see also the file “examples/wizard.rb”)

General Notes¶ ↑

Methods are callable directly on the Prompter class, on a Prompter object, included in your class as instance methods or class methods.

Some methods yield the block with the returned value, so you can use them as an easy way to construct hierarchical wizards.

The Prompter.dye_styles keys are passable as the :style option to the called method and will override the default styles, They can also be redefined by setting the Prompter.dye_styles. (see the ‘dye’ gem for more info)

Documentation and Example¶ ↑

All the methods are yard-documented, and there is and ‘example/wizard.rb’ that could be useful.

Copyright © 2010-2012 Domizio Demichelis. See LICENSE for details.