# Error in Lib file function

**URL:** <https://www.ruby-forum.com/t/error-in-lib-file-function/130342>\
**Category:** Rails\
**Created:** [February 27, 2008, 2:58pm UTC](https://www.ruby-forum.com/t/error-in-lib-file-function/130342 "2008-02-27T14:58:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasan\_cec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vasan\_cec](https://www.ruby-forum.com/u/vasan_cec)\
**Post date:** [February 27, 2008, 2:58pm UTC](https://www.ruby-forum.com/t/error-in-lib-file-function/130342/1 "2008-02-27T14:58:39Z")

</div>

Hi Everyone,  
I have the following two functions in “global\_functions.rb”,

```
# Decription : Function to get minimum between two input values
# Input : x & y - any two number
# Output : Minimum number of 2 input values
def self.getMinimumValue(x, y)
  if(x <= y)
    @min_value = x
  else
    @min_value = y
  end
  return @min_value
end

# Decription : Function to get maximum between two input values
# Input : x & y - any two number
# Output : Maximum number of 2 input values
def self.getMaximumValue(x, y)
  if(x >= y)
    @max_value = x
  else
    @max_value = y
  end
  return @max_value
end

```

So, If i try to access “getMaximumValue” like  
GlobalFunctions.getMaximumValue it shows an error like “undefined method  
`getMaximumValue` for GlobalFunctions:Class”.  
However, if i remove “getMaximumValue” from that file and have only  
“getMinimumValue” then its working fine. I dont know how this is  
working. Is there any function limit for a Lib class?

Please help me out of this problem.  
Thanks in advance.  
Regards,  
VASANTH

---

<div class="post-metadata">

**Author:** ![vasan\_cec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vasan\_cec](https://www.ruby-forum.com/u/vasan_cec)\
**Post date:** [February 27, 2008, 3:09pm UTC](https://www.ruby-forum.com/t/error-in-lib-file-function/130342/2 "2008-02-27T15:09:15Z")

</div>

On 27 Feb 2008, at 13:58, Vasanthakumar C. wrote:

> So, If i try to access “getMaximumValue” like  
> GlobalFunctions.getMaximumValue it shows an error like “undefined  
> method  
> `getMaximumValue` for GlobalFunctions:Class”.  
> However, if i remove “getMaximumValue” from that file and have only  
> “getMinimumValue” then its working fine. I dont know how this is  
> working. Is there any function limit for a Lib class?

It’s probably something to do with the other bits of that file.  
There’s certainly no limit on the number of methods you can declare  
(although you could rewrite those functions as [x,y].min and [x,y].max

Fred

---

<div class="post-metadata">

**Author:** ![vasan\_cec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vasan\_cec](https://www.ruby-forum.com/u/vasan_cec)\
**Post date:** [February 27, 2008, 3:32pm UTC](https://www.ruby-forum.com/t/error-in-lib-file-function/130342/3 "2008-02-27T15:32:50Z")

</div>

Hi Cheung…thanks for ur suggestion.  
And i have found the reason for my error, its the file name  
“global\_functions.rb”. Which i changed to “global\_function.rb” and  
accessed the functions like GlobalFunction.getMaximumValue.  
Now everything is working fine. Even though i found the problem, i am  
not sure why it is behaving like that. Is it related to that  
singular/plural naming conventions that Rails follows?  
Is there any explanation for this? Just curious to know the actual  
problem.

Thanks in advance.  
Regards,  
VASANTH

Frederick C. wrote:

> On 27 Feb 2008, at 13:58, Vasanthakumar C. wrote:
> 
> > So, If i try to access “getMaximumValue” like  
> > GlobalFunctions.getMaximumValue it shows an error like “undefined  
> > method  
> > `getMaximumValue` for GlobalFunctions:Class”.  
> > However, if i remove “getMaximumValue” from that file and have only  
> > “getMinimumValue” then its working fine. I dont know how this is  
> > working. Is there any function limit for a Lib class?
> 
> It’s probably something to do with the other bits of that file.  
> There’s certainly no limit on the number of methods you can declare  
> (although you could rewrite those functions as [x,y].min and [x,y].max
> 
> Fred
