Questions tagged as 'ruby'

3
answers

check if it has a comma and delete a comma if it is in the string by Ruby

Hi, how do I delete a string to check if the last variable's string word is a comma, and how do I delete that comma at the end of the string type variable? test="my name is neymar," Then leave test="my name is neymar" In Ruby code I need...
asked by 19.04.2018 / 14:58
1
answer

Display highest frequency word per line and calculate number of words per line

I have the following text and I have to display the words that appear most frequently per line and calculate number of words for each line This is a really really really cool experiment really Cute little experiment Will it work maybe it wi...
asked by 04.01.2018 / 01:33
1
answer

How to convert an object to boolean in Ruby?

Objects in Ruby have some methods for rendering into another type, such as: to_s : convert to string to_a : convert to array to_i : convert to integer to_f : convert to float But there is no standard meth...
asked by 27.12.2017 / 04:09
1
answer

ArgumentError when calling function

I'm trying to run this code below: class ProdutItem attr_reader :price_unit, :x_item, :price_promo def initialize(price_unit: , x_item: 1, price_promo: price_unit) @price_unit = price_unit @x_item = x_item @price_promo = pric...
asked by 15.12.2017 / 19:28
1
answer

Implementation of the NRS Gateway API

I need to implement a nrs gateway api for sending sms, for this it is necessary to make a URL request with the necessary parameters, but I do not know if I use GET or REST to do this, what is it recommendable to use? link     
asked by 22.12.2017 / 17:31
1
answer

Do programs written in Ruby work on both Windows and Linux?

It's a question I have about this programming language. Java , for example, has no OS distinction, as it has something like an internal SO , so no you need a specific port for each SO . The same code works for both Linux and Windows, how...
asked by 27.09.2017 / 05:29
1
answer

Assertion with Rspec

I use the Cucumber + Capybara + Ruby framework and I'm not able to make an assertion using the "expect" method. I need to, for example, validate four messages returned in the body, but displays error: Expected: "sunt aut facere repellat pr...
asked by 19.09.2017 / 14:09
1
answer

syntax error, unexpected (arg, expecting end-of-input)

I came across this syntax error:    syntax error, unexpected (arg, expecting end-of-input) larguraDaLinha = 40 str = '--> text <--' puts str.ljust larguraDaLinha puts str.center larguraDaLinha puts str.rjust larguraDaLinha puts str...
asked by 10.09.2017 / 00:13
1
answer

How to make a search field with form_tag in rails?

Hello! Good afternoon. I'm an information systems student and I'm doing a small project where I need to put a form to fetch the Product template objects that exist in the database. Product template: class Produto < ApplicationRecord be...
asked by 07.06.2017 / 20:12
1
answer

rails rspec, error in post: create, params require

I'm starting the rspec tests in RubyOnRails and I'm having a problem testing my controller's create: it "creates lançamento" do post :create, params: attributes_for(:lancamento), format: :js, xhr: true expect(Lancamento.count).to eq(1) end...
asked by 11.04.2017 / 16:33