Sha256: 1dc38c07cdf3653890b54d4cbe1111ec482244dc399f9dcf4dec3e0dd540107e

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

require_relative 'BaseAction.rb'

#noinspection RubyResolve
module PPCurses

# An action that contains an array of prompt actions.  
# It can be used to group together multiple prompt actions.
#
class GetDataAction < BaseAction

  def initialize( actions )
    @actions = actions
    unless @actions.nil?
      @actions.each  do |action|
         action.set_parent_action(self)
      end
    end
  end

  def before_actions
    # Stub for classes that extend
  end

  def after_actions
    # Stub for classes that extend
  end


  def data
    values = []
    @actions.each  do |action|
       values.push( action.data )
    end
    values
  end

  def create_window
    super()
    # Assign window to actions
    unless @actions.nil?
      @actions.each  do |action|
         action.set_window(@win)
      end
    end
  end

  def execute
    create_window
    echo

    @win.setpos(@win.cury, x_padding )

    self.before_actions
    
    @actions.each  do |action|
      action.execute
    end

    self.after_actions

    noecho
    @win.clear 
    @win.refresh
    @win.close
  end

  def print_line(string)
    @win.setpos(@win.cury, win_padding)
    @win.addstr(string)
    @win.setpos(@win.cury + 1, win_padding)
  end

  def print_success_line(string)
    init_pair(1, COLOR_GREEN, COLOR_BLACK)
    @win.attron(color_pair(1))
    self.print_line(string)
    @win.attroff(color_pair(1))
  end

  def print_error_line(string)
    init_pair(1, COLOR_RED, COLOR_BLACK)
    @win.attron(color_pair(1))
    self.print_line(string)
    @win.attroff(color_pair(1))
  end



end

end 

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ppcurses-0.0.25 lib/ppcurses/actions/GetDataAction.rb