Is there any difference between ERB#run and ERB#result

I am wondering if there is any difference between

and
Class: ERB (Ruby 2.1.1).
Is there any ?

I am reading - http://rrn.dk/rubys-erb-templating-system and
ERB - APIdock … Didn’t find any difference.

On Sat, Mar 15, 2014 at 7:55 PM, Arup R. [email protected]
wrote:

I am wondering if there is any difference between

Class: ERB (Ruby 2.1.1)
and
Class: ERB (Ruby 2.1.1).
Is there any ?

Click the toggler to see the source code.

Xavier N. wrote in post #1139990:

On Sat, Mar 15, 2014 at 7:55 PM, Arup R. [email protected]
wrote:

Click the toggler to see the source code.

Humm… Xavier. I did it… #run calling #result inside it. No idea, why
then #run is needed in the API. That’s a my question. Because in CSV
module, I found lot’s of such things, where docs saying same, but they
are not. I found 1 bug, and some other wrong documentation. Verified by
JEGII, who used to tell you Ruby Hero :slight_smile:

On Sat, Mar 15, 2014 at 9:05 PM, Arup R. [email protected]
wrote:

I know they are different library … I meant to say, currently I am not

taking any risks… :slight_smile: May be something there between those 2 methods
(#run and #result), but not documented.

I guess there is a misunderstanding somewhere, ERB#run says in its
documentation that it prints the result.

Maybe you interpret something else due to some issue with the English
sentence?

Xavier N. wrote in post #1139992:

On Sat, Mar 15, 2014 at 8:47 PM, Arup R. [email protected]
wrote:

ERB and CSV have nothing to do, their APIs may not be coherent between
each
other, but that’s not their goal, if that is true that’s fine, it is
apples
and oranges.

I know they are different library … I meant to say, currently I am not
taking any risks… :slight_smile: May be something there between those 2 methods
(#run and #result), but not documented. So I asked here to experts, if
they have anything to share… :slight_smile:

On Sat, Mar 15, 2014 at 8:47 PM, Arup R. [email protected]
wrote:

Xavier N. wrote in post #1139990:

are not. I found 1 bug, and some other wrong documentation. Verified by
JEGII, who used to tell you Ruby Hero :slight_smile:

Yeah, you could just remove the method, but having the method is equally
valid.

Sometimes libraries have convenience methods like that, in Perl land for
example this one-liner is legendary:

perl -MLWP::Simple -e 'getprint "http://www.sn.no"'

Why getprint? Well, no big deal, the author just wanted to provide the
shortcut.

ERB and CSV have nothing to do, their APIs may not be coherent between
each
other, but that’s not their goal, if that is true that’s fine, it is
apples
and oranges.

On Sat, Mar 15, 2014 at 3:27 PM, Arup R. [email protected]
wrote:

I got it now they will work same way ( only 2 doors for the same room ),
as you involved… :slight_smile:

No, they are different.

run calls result and prints it, as in displays it on STDOUT.

result merely returns the processed input as a string.

Xavier N. wrote in post #1139995:

On Sat, Mar 15, 2014 at 9:05 PM, Arup R. [email protected]
wrote:

I guess there is a misunderstanding somewhere, ERB#run says in its
documentation that it prints the result.

Maybe you interpret something else due to some issue with the English
sentence?

I got it now they will work same way ( only 2 doors for the same room ),
as you involved… :slight_smile:

Thank you very much for your time as always.

tamouse m. wrote in post #1140013:

On Sat, Mar 15, 2014 at 3:27 PM, Arup R. [email protected]

No, they are different.

run calls result and prints it, as in displays it on STDOUT.

result merely returns the processed input as a string.

Yes, In my case I was using puts with both, thus couldn’t catch the
difference. Now I tried as you said, got the difference :

#run

require ‘erb’

name = “Arup” # !> assigned but unused variable - name
template_string = “My name is <%= name %>”
template = ERB.new template_string
template.run

>> My name is Arup

#result

require ‘erb’

name = “Arup” # !> assigned but unused variable - name
template_string = “My name is <%= name %>”
template = ERB.new template_string
template.result # no output.

Thank you very much.