{"id":4011,"date":"2016-08-09T02:18:39","date_gmt":"2016-08-08T20:48:39","guid":{"rendered":"https:\/\/www.botreetechnologies.com\/blog\/?p=4011"},"modified":"2020-12-08T17:34:48","modified_gmt":"2020-12-08T12:04:48","slug":"how-to-extend-float-class-in-ruby","status":"publish","type":"post","link":"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/","title":{"rendered":"How To Extend Float Class in Ruby"},"content":{"rendered":"\n<p>Sometimes we need to customize Ruby classes. I am going to introduce how to extend the Ruby Float class in simple steps.<\/p>\n\n\n\n<p>As we are going to extend, create an extensions folder inside lib and create a float.rb inside this folder.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><i><code>lib\/extensions\/float.rb<\/code><\/i><\/p><\/blockquote>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/ChetanTomar\/d192a6625d0470eb3c25c04da07ea09d.js\"><\/script><\/p>\n\n\n\n<p>Now we need to initialize this module when application starts so that we can access this method in entire application. Create a file load_extensions.rb in initializers<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><i><code>config\/initializers\/load_extensions.rb<\/code><\/i><\/p><\/blockquote>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/ChetanTomar\/b0c77071f272151653ef96ba688c9b5c.js\"><\/script><\/p>\n\n\n\n<p>Now restart your server; that&#8217;s it. Now you can apply this&nbsp;<code>with_precision()<\/code>&nbsp;on float object anywhere in Application.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.botreetechnologies.com\/ruby-on-rails-development\"><b>Cli<\/b><strong><b>ck here for more<\/b> details&#8230;<\/strong><\/a><\/p>\n\n\n\n<p>At<a href=\"https:\/\/www.botreetechnologies.com\/\"> BoTree Technologies<\/a>, we build enterprise applications with our <a href=\"https:\/\/www.botreetechnologies.com\/hire-ruby-on-rails-developers\" target=\"_blank\" rel=\"noopener noreferrer\">RoR team of 25+ engineers<\/a>.<\/p>\n\n\n\n<p>We also specialize in Python, RPA, AI, Django, JavaScript and ReactJS.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/www.botreetechnologies.com\/contact\">Consulting is free<\/a> &#8211; let us help you grow!<\/h3>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes we need to customize Ruby classes. I am going&#8230;<\/p>\n","protected":false},"author":20,"featured_media":13957,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73,10],"tags":[],"class_list":["post-4011","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ruby-on-rails","category-technology"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How To Extend Float Class in Ruby<\/title>\n<meta name=\"description\" content=\"Sometimes we need to customize Ruby classes. I am going to introduce how to extend the Ruby Float class in simple steps.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Extend Float Class in Ruby\" \/>\n<meta property=\"og:description\" content=\"Sometimes we need to customize Ruby classes. I am going to introduce how to extend the Ruby Float class in simple steps.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/\" \/>\n<meta property=\"og:site_name\" content=\"BoTree Technologies\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/BoTreeTechnologies\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-08-08T20:48:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-08T12:04:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/08\/float-class-in-ruby.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1280\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Chetan Tomar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@BoTreeTech\" \/>\n<meta name=\"twitter:site\" content=\"@BoTreeTech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Chetan Tomar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/\"},\"author\":{\"name\":\"Chetan Tomar\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/821bdcbee2e598676d9028dc6e7a6fdb\"},\"headline\":\"How To Extend Float Class in Ruby\",\"datePublished\":\"2016-08-08T20:48:39+00:00\",\"dateModified\":\"2020-12-08T12:04:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/\"},\"wordCount\":136,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/08\/float-class-in-ruby.jpg\",\"articleSection\":[\"Ruby on Rails\",\"Technology\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/\",\"name\":\"How To Extend Float Class in Ruby\",\"isPartOf\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/08\/float-class-in-ruby.jpg\",\"datePublished\":\"2016-08-08T20:48:39+00:00\",\"dateModified\":\"2020-12-08T12:04:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/821bdcbee2e598676d9028dc6e7a6fdb\"},\"description\":\"Sometimes we need to customize Ruby classes. I am going to introduce how to extend the Ruby Float class in simple steps.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#primaryimage\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/08\/float-class-in-ruby.jpg\",\"contentUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/08\/float-class-in-ruby.jpg\",\"width\":1920,\"height\":1280,\"caption\":\"Extend Float Class In Ruby\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.botreetechnologies.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Extend Float Class in Ruby\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#website\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/\",\"name\":\"BoTree Technologies\",\"description\":\"Committed to inspire generation.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.botreetechnologies.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/821bdcbee2e598676d9028dc6e7a6fdb\",\"name\":\"Chetan Tomar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/chetan-tomar-150x150.png\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/chetan-tomar-150x150.png\",\"contentUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/chetan-tomar-150x150.png\",\"caption\":\"Chetan Tomar\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Extend Float Class in Ruby","description":"Sometimes we need to customize Ruby classes. I am going to introduce how to extend the Ruby Float class in simple steps.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/","og_locale":"en_US","og_type":"article","og_title":"How To Extend Float Class in Ruby","og_description":"Sometimes we need to customize Ruby classes. I am going to introduce how to extend the Ruby Float class in simple steps.","og_url":"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/","og_site_name":"BoTree Technologies","article_publisher":"https:\/\/www.facebook.com\/BoTreeTechnologies\/","article_published_time":"2016-08-08T20:48:39+00:00","article_modified_time":"2020-12-08T12:04:48+00:00","og_image":[{"width":1920,"height":1280,"url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/08\/float-class-in-ruby.jpg","type":"image\/jpeg"}],"author":"Chetan Tomar","twitter_card":"summary_large_image","twitter_creator":"@BoTreeTech","twitter_site":"@BoTreeTech","twitter_misc":{"Written by":"Chetan Tomar","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#article","isPartOf":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/"},"author":{"name":"Chetan Tomar","@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/821bdcbee2e598676d9028dc6e7a6fdb"},"headline":"How To Extend Float Class in Ruby","datePublished":"2016-08-08T20:48:39+00:00","dateModified":"2020-12-08T12:04:48+00:00","mainEntityOfPage":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/"},"wordCount":136,"commentCount":0,"image":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#primaryimage"},"thumbnailUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/08\/float-class-in-ruby.jpg","articleSection":["Ruby on Rails","Technology"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/","url":"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/","name":"How To Extend Float Class in Ruby","isPartOf":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#primaryimage"},"image":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#primaryimage"},"thumbnailUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/08\/float-class-in-ruby.jpg","datePublished":"2016-08-08T20:48:39+00:00","dateModified":"2020-12-08T12:04:48+00:00","author":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/821bdcbee2e598676d9028dc6e7a6fdb"},"description":"Sometimes we need to customize Ruby classes. I am going to introduce how to extend the Ruby Float class in simple steps.","breadcrumb":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#primaryimage","url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/08\/float-class-in-ruby.jpg","contentUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/08\/float-class-in-ruby.jpg","width":1920,"height":1280,"caption":"Extend Float Class In Ruby"},{"@type":"BreadcrumbList","@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-extend-float-class-in-ruby\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.botreetechnologies.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How To Extend Float Class in Ruby"}]},{"@type":"WebSite","@id":"https:\/\/www.botreetechnologies.com\/blog\/#website","url":"https:\/\/www.botreetechnologies.com\/blog\/","name":"BoTree Technologies","description":"Committed to inspire generation.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.botreetechnologies.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/821bdcbee2e598676d9028dc6e7a6fdb","name":"Chetan Tomar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/chetan-tomar-150x150.png","url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/chetan-tomar-150x150.png","contentUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/chetan-tomar-150x150.png","caption":"Chetan Tomar"}}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/4011","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=4011"}],"version-history":[{"count":2,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/4011\/revisions"}],"predecessor-version":[{"id":13958,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/4011\/revisions\/13958"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/media\/13957"}],"wp:attachment":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=4011"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=4011"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=4011"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}