Sha256: bcd9cb2bd983af90200f4b718b7a5ca2146abea06e182f4acc48c836bc687cec

Contents?: true

Size: 877 Bytes

Versions: 2

Compression:

Stored size: 877 Bytes

Contents

# File: char_class.rb

require_relative "polyadic_expression"	# Access the superclass

module Regex # This module is used as a namespace

# Abstract class. A n-ary matching operator. 
# It succeeds when one child expression succeeds to match the subject text
# than defined by this concatenation.
class CharClass < PolyadicExpression
	# A flag that indicates whether the character is negated
	attr_reader(:negated)
	
	# Constructor.
	def initialize(to_negate,*theChildren)
		super(theChildren)
		@negated = to_negate
	end

public
	# Conversion method re-definition.
	# Purpose: Return the String representation of the concatented expressions.
	def to_str()
		result_children = children.inject('') { |subResult, aChild| subResult << aChild.to_str() }
		result = '['+ (negated ? '^' : '')  + result_children + ']'
		
		return result
	end

end # class

end # module

# End of file

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rley-0.5.10 examples/general/SRL/lib/regex/char_class.rb
rley-0.5.09 examples/general/SRL/lib/regex/char_class.rb