Sha256: a0f7497f1a159c34817378dcecc17ec7909f56526cad415b212276d1ab5ee42b

Contents?: true

Size: 1.62 KB

Versions: 7

Compression:

Stored size: 1.62 KB

Contents

#
#--
# Ronin - A Ruby platform designed for information security and data
# exploration tasks.
#
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#++
#

module Ronin
  module Code
    module Emittable
      #
      # Default emit method which simply returns +nil+.
      #
      def emit
        []
      end

      protected

      #
      # Emits a Token with the specified _name_.
      #
      def emit_token(name)
        [Token.new(name)]
      end

      #
      # Emits the specified _value_ if _value_ is an Emittable object,
      # otherwise _value_ will be returned.
      #
      def emit_value(value)
        if value.kind_of?(Emittable)
          return value.emit
        else
          return [value]
        end
      end

      #
      # Emits each of the specified _valueis_.
      #
      def emit_values(values)
        values.inject([]) { |tokens,value| tokens + emit_value(value) }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ronin-0.2.4 lib/ronin/code/emittable.rb
ronin-0.1.3 lib/ronin/code/emittable.rb
ronin-0.1.4 lib/ronin/code/emittable.rb
ronin-0.2.1 lib/ronin/code/emittable.rb
ronin-0.2.0 lib/ronin/code/emittable.rb
ronin-0.2.2 lib/ronin/code/emittable.rb
ronin-0.2.3 lib/ronin/code/emittable.rb