Class: Peruby::Glob

Inherits:
Object
  • Object
show all
Defined in:
lib/peruby/runtime/glob.rb

Overview

Five independent value slots associated with one Perl symbol name.

Constant Summary collapse

SLOTS =
%i[scalar array hash code io].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full_name) ⇒ Glob

Returns a new instance of Glob.



11
12
13
14
15
16
# File 'lib/peruby/runtime/glob.rb', line 11

def initialize(full_name)
  @full_name = full_name
  @scalar = Scalar.new
  @array = PerlArray.new
  @hash = PerlHash.new
end

Instance Attribute Details

#full_nameObject (readonly)

Returns the value of attribute full_name.



8
9
10
# File 'lib/peruby/runtime/glob.rb', line 8

def full_name
  @full_name
end

Instance Method Details

#replace(slot, value) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
# File 'lib/peruby/runtime/glob.rb', line 18

def replace(slot, value)
  raise ArgumentError, "unknown glob slot: #{slot}" unless SLOTS.include?(slot)

  public_send("#{slot}=", value)
end