403Webshell
Server IP : 66.29.132.122  /  Your IP : 3.141.28.107
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/proc/self/root/proc/thread-self/root/proc/thread-self/root/opt/puppetlabs/puppet/lib/ruby/vendor_gems/gems/highline-2.1.0/lib/highline/question/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/proc/self/root/proc/thread-self/root/proc/thread-self/root/opt/puppetlabs/puppet/lib/ruby/vendor_gems/gems/highline-2.1.0/lib/highline/question/answer_converter.rb
# coding: utf-8

require "forwardable"

class HighLine
  class Question
    # It provides all answer conversion flow.
    class AnswerConverter
      extend Forwardable

      def_delegators :@question,
                     :answer, :answer=, :check_range,
                     :directory, :answer_type, :choices_complete

      # It should be initialized with a Question object.
      # The class will get the answer from {Question#answer}
      # and then convert it to the proper {Question#answer_type}.
      # It is mainly used by {Question#convert}
      #
      # @param question [Question]
      def initialize(question)
        @question = question
      end

      # Based on the given Question object's settings,
      # it makes the conversion and returns the answer.
      # @return [Object] the converted answer.
      def convert
        return unless answer_type

        self.answer = convert_by_answer_type
        check_range
        answer
      end

      # @return [HighLine::String] answer converted to a HighLine::String
      def to_string
        HighLine::String(answer)
      end

      # That's a weird name for a method!
      # But it's working ;-)
      define_method "to_highline::string" do
        HighLine::String(answer)
      end

      # @return [Integer] answer converted to an Integer
      def to_integer
        Kernel.send(:Integer, answer)
      end

      # @return [Float] answer converted to a Float
      def to_float
        Kernel.send(:Float, answer)
      end

      # @return [Symbol] answer converted to an Symbol
      def to_symbol
        answer.to_sym
      end

      # @return [Regexp] answer converted to a Regexp
      def to_regexp
        Regexp.new(answer)
      end

      # @return [File] answer converted to a File
      def to_file
        self.answer = choices_complete(answer)
        File.open(File.join(directory.to_s, answer.last))
      end

      # @return [Pathname] answer converted to an Pathname
      def to_pathname
        self.answer = choices_complete(answer)
        Pathname.new(File.join(directory.to_s, answer.last))
      end

      # @return [Array] answer converted to an Array
      def to_array
        self.answer = choices_complete(answer)
        answer.last
      end

      # @return [Proc] answer converted to an Proc
      def to_proc
        answer_type.call(answer)
      end

      private

      def convert_by_answer_type
        if answer_type.respond_to? :parse
          answer_type.parse(answer)
        elsif answer_type.is_a? Class
          send("to_#{answer_type.name.downcase}")
        else
          send("to_#{answer_type.class.name.downcase}")
        end
      end
    end
  end
end

Youez - 2016 - github.com/yon3zu
LinuXploit