There are multiple errors.
Preamble: type
and name
are no standard methods. In the following example I replace it with strings.
When you use Here-Documents like this:
puts <<HEREDOC
Heredoc
HEREDOC
Then the closing HEREDOC
must start in column 0 and may have no trailing spaces. When you have leading spaces, then you must start with <<-HEREDOC
:
puts <<-HEREDOC
Heredoc
HEREDOC
So your example is:
def whatClass()
class_type = 'type' #self.type undefined method `type'
class_name = 'name' #self.name
puts <<-TYPE, <<-EOF, <<-NAME
class_type
TYPE
\n
EOF
class_name
NAME
end
And again: There may be no trailing spaces in TYPE
, EOF
and NAME
(when I take your example with cut+paste there are trailing spaces at NAME
).
The next error:
The output is
class_type
class_name
But I think you want the content of the two variables. So I think you need:
def whatClass()
class_type = 'type' #self.type undefined method `type'
class_name = 'name' #self.name
puts <<-TYPE, <<-EOF, <<-NAME
#{class_type}
TYPE
\n
EOF
#{class_name}
NAME
end