<Bish>
shouldn't this work? or do i have to go around that with class_variable_get ?
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
<pavelz>
hi if I include code from class and run module on instance is self.class.instance_variable_get is a best way to access instance variables or is there a prettier way ?
<pavelz>
module method included in class to access instance variable from object instantiated from a class that includes said module and its methods.
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
deepreds1 has joined #ruby
<phaul>
I have difficulty parsing "if I include code from class and run module on instance". Maybe show us a small code example of what you mean
<Bish>
.instance_eval and that are the both possibilities you have, i guess
<phaul>
fwiw you can't include a class
<Bish>
was wondering about that one, too :o
donofrio has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
MrCrackPot has joined #ruby
Ven`` has joined #ruby
deepreds1 has quit [Ping timeout: 268 seconds]
<pavelz>
:) i mean include module in class and access class instance variable from module. thank you!
baojg_ has quit [Ping timeout: 246 seconds]
<Bish>
if you access an instance variable from a module, it will try to find that instance variable at time of execution
kyrylo has quit [Client Quit]
<Bish>
the method's code is agnostic to what instance it is bound too..
<phaul>
I would probably have an attr_reader and access it via that. As it's used externally not inside the class but external module, I would also document it and make it part of the API of the class
za1b1tsu has quit [Remote host closed the connection]
baojg has joined #ruby
<phaul>
Also the module should document that it needs the including class to have a set of methods with this attr_reader being there
<Bish>
maybe it's used by both, though
<phaul>
I'm speculating ofc on the exact use case, but sometimes one wants to decorate classes with bunch of methods assuming some minimal API provided by the classes
<phaul>
like Comparable assuming spaceship. just in this case assuming the attr_reader
<Bish>
i don't like the idea of every instance variable having a getter & setter, maybe it's jus tsome container of some sort
<phaul>
no, I'm not saying you should have a getter and setter for all instance variables. But for that instance var I would to fullfil the requirement of the including module. Like Comparable docs says: "Comparable uses <=> to implement the conventional comparison operators (<, <=, ==, >=, and >) ..."
<phaul>
so the contract of inclusion is to have <=>. Here the contract of inclusion is to have a method that the class happens to implement via an attr_reader - or whichever way they want
baojg has quit [Ping timeout: 245 seconds]
<phaul>
includ_ed_ module**
dionysus69 has quit [Quit: ZNC 1.7.2+deb3 - https://znc.in]
dionysus70 has joined #ruby
baojg has joined #ruby
dionysus70 has quit [Client Quit]
drale2k_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
greengriminal has quit [Quit: This computer has gone to sleep]
baojg has quit [Ping timeout: 272 seconds]
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
greengriminal has joined #ruby
<phaul>
also you can add a method to the module raising an exception if it's called, making sure that the class overrides it
drale2k_ has joined #ruby
duderonomy has joined #ruby
conta1 has joined #ruby
giraffe has joined #ruby
tpendragon has joined #ruby
tim17d has quit [Remote host closed the connection]
tim17d has joined #ruby
tipyn has joined #ruby
sgen has joined #ruby
TomyWork has quit [Ping timeout: 246 seconds]
sgen has quit [Ping timeout: 264 seconds]
sagax has quit [Remote host closed the connection]
baojg has quit [Remote host closed the connection]
<havenwood>
I like having a non-Rails-entangled version of gems, for sure!
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
Azure|dc has joined #ruby
baojg has quit [Remote host closed the connection]
<leitz>
havenwood, I keep second-guessing myself on which language to focus on. Drives me nuts. Of course...it's a short trip...
<havenwood>
leitz: Ruby, of course!
baojg has joined #ruby
RiPuk has joined #ruby
baojg has quit [Remote host closed the connection]
Azure has quit [Ping timeout: 246 seconds]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
<leitz>
The pseudo interview from a friend, and actual interview for this job, had "write code and send it to me" parts. I did it in Ruby. Interestingly, no one seems to specify what language you have to interview in.
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
<havenwood>
Yeah, I've noticed so many companies want you to complete a task in any language of your choosing. It's quite rare for the language to be specified.
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
NL3limin4t0r has quit [Quit: WeeChat 1.9.1]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
<leitz>
My concern isn't that Ruby can't do stuff, the more I study the more amazed I am. The issue is that as a contractor who just moved to being a programmer, my skills aren't up to that of most other programmers my age.
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
<leitz>
Having their specific language as a skill would help, but Ruby is the one I'm learning the most in.
<havenwood>
leitz: What are you learning the most in?
baojg has joined #ruby
<leitz>
Ruby.
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
<leitz>
First language I've ever wanted to come home and hand copy notes from the reference manual.
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
<leitz>
In the evenings I'm making my flash card deck.
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
<havenwood>
Oh, I totally misread. You said Ruby. Right!
baojg has joined #ruby
<havenwood>
I got it backwards.
<leitz>
Empty coffee cup? :)
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
* havenwood
goes in search of coffee
baojg has joined #ruby
<leitz>
I'm just getting to understand OOP enough to actually use it.
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
drale2k_ has joined #ruby
ravenou__ has joined #ruby
baojg has quit [Remote host closed the connection]
NL3limin4t0r has joined #ruby
baojg has joined #ruby
RiPuk has quit [Ping timeout: 248 seconds]
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
baojg has quit [Remote host closed the connection]
RiPuk has joined #ruby
ravenous_ has quit [Ping timeout: 264 seconds]
ravenou__ has quit [Read error: Connection reset by peer]
<leitz>
Which can be a limiting factor in a strongly object oriented language.
ravenous_ has joined #ruby
kyrylo has joined #ruby
RiPuk has quit [Ping timeout: 248 seconds]
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
Fischmiep has joined #ruby
Fischmiep has quit [Client Quit]
greengriminal has quit [Quit: This computer has gone to sleep]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
fphilipe_ has quit [Ping timeout: 268 seconds]
Fischmiep has joined #ruby
Fischmiep has quit [Client Quit]
cthulchu_ has quit [Read error: Connection reset by peer]
conta1 has joined #ruby
cthulchu_ has joined #ruby
fphilipe_ has joined #ruby
greengriminal has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
Ven`` has joined #ruby
fphilipe_ has quit [Ping timeout: 252 seconds]
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
gix has joined #ruby
kyrylo has quit [Read error: Connection reset by peer]
kyrylo has joined #ruby
kyrylo has quit [Client Quit]
sagax has joined #ruby
lxsameer has quit [Quit: out]
ellcs1 has joined #ruby
fphilipe_ has joined #ruby
ellcs1 has quit [Ping timeout: 264 seconds]
RiPuk has joined #ruby
ramfjord has joined #ruby
ellcs1 has joined #ruby
Fischmiep has joined #ruby
chalkmonster has joined #ruby
cd has joined #ruby
RiPuk has quit [Ping timeout: 272 seconds]
tdy1 has joined #ruby
cthulchu_ has quit [Ping timeout: 244 seconds]
tdy has quit [Ping timeout: 244 seconds]
tdy1 has quit [Client Quit]
cthulchu_ has joined #ruby
sauvin has quit [Ping timeout: 272 seconds]
<leitz>
havenwood must have gone to Columbia for fresh coffee. :)
chalkmonster has quit [Quit: WeeChat 2.5]
greengriminal has quit [Quit: This computer has gone to sleep]
Fischmiep has quit [Read error: Connection reset by peer]
RiPuk has joined #ruby
Fischmiep has joined #ruby
duderonomy has joined #ruby
greengriminal has joined #ruby
suukim has quit [Quit: Konversation terminated!]
tipyn has quit [Remote host closed the connection]
tipyn has joined #ruby
tipyn has quit [Ping timeout: 258 seconds]
conta1 has quit [Ping timeout: 258 seconds]
tdy has joined #ruby
fphilipe_ has quit [Ping timeout: 252 seconds]
Fischmiep has quit [Ping timeout: 264 seconds]
yann-kaelig has joined #ruby
ramfjord has quit [Ping timeout: 258 seconds]
involans has quit [Quit: involans]
bmurt has quit [Ping timeout: 246 seconds]
bmurt has joined #ruby
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has quit [Ping timeout: 244 seconds]
titanbiscuit has quit [Read error: Connection reset by peer]
elphe has quit [Ping timeout: 272 seconds]
<yann-kaelig>
Hi. I noticed that an installation from a debian package do not install all the files like a gem install command line. MOst packages coming from debian for example do not install the test folder. I suppose, because I do not found a clear explanation about this this folder. Is it only necessary for developers, compilation time ? but I can be wrong. Someone could be able to lighten me ?
fphilipe_ has joined #ruby
jenrzzz has joined #ruby
grilix has quit [Ping timeout: 248 seconds]
fphilipe_ has quit [Ping timeout: 252 seconds]
jenrzzz has quit [Ping timeout: 245 seconds]
tipyn has joined #ruby
tipyn has quit [Ping timeout: 272 seconds]
codefriar has quit [Ping timeout: 245 seconds]
MrCrackPot has quit [Ping timeout: 258 seconds]
x86sk has joined #ruby
codefriar has joined #ruby
tpanarch1st has joined #ruby
involans has joined #ruby
jenrzzz has joined #ruby
<leitz>
yann-kaelig, I think you're right, usually a "test" directory is for the automated tests of the software. Or the gem. Some developers ship them, some do now.
<leitz>
now/not.
MrCrackPot has joined #ruby
jenrzzz has quit [Ping timeout: 244 seconds]
MrCrackPot has quit [Ping timeout: 245 seconds]
Fischmiep has joined #ruby
Fischmiep has quit [Ping timeout: 264 seconds]
ravenous_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
redlegion has quit [Ping timeout: 246 seconds]
ramfjord has joined #ruby
VladGh has joined #ruby
SeepingN_ has joined #ruby
SeepingN has quit [Disconnected by services]
jenrzzz has joined #ruby
<havenwood>
yann-kaelig: +1 test and spec directories are for tests, which is code for developers that confirms the gem works as expected with automated units tests for small portions of code and integration tests to confirm the parts work together.
<yann-kaelig>
hi leitz, havenwood.
<yann-kaelig>
thx
titanbiscuit has joined #ruby
<yann-kaelig>
I have to package/repackage some ruby gems which will be used for a server prod. With some difficulty I'm trying to find all this development pieces, which from my point of view has nothing to do on a server
<yann-kaelig>
Perhaps I missed some usefull information on the gem website , but I don't know where I could find this info.
tipyn has joined #ruby
sagax has quit [Remote host closed the connection]
ur5us has joined #ruby
ur5us has quit [Read error: Connection reset by peer]
ur5us has joined #ruby
jenrzzz_ has joined #ruby
SeepingN_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has quit [Ping timeout: 245 seconds]
<darix>
yann-kaelig: it is not usually encoded somewhere on rubygems.org
jcalla has quit [Quit: Leaving]
<darix>
yann-kaelig: and some gems even ship the C libraries intree but support building against system copies (if you prefer that)
SeepingN has joined #ruby
Fischmiep has joined #ruby
<darix>
havenwood: that didnt stop some devs to have runtime dependencies on their tests directories :D
Fischmiep has quit [Ping timeout: 250 seconds]
tipyn has quit [Remote host closed the connection]
fphilipe_ has joined #ruby
evdubs has quit [Quit: Leaving]
evdubs has joined #ruby
tpanarch1st has quit [Quit: Thanks for your help, nice to see you, take care.]
ellcs1 has quit [Ping timeout: 264 seconds]
Frobozz has joined #ruby
fphilipe_ has quit [Ping timeout: 252 seconds]
Frobozz has quit [Remote host closed the connection]
Frobozz has joined #ruby
SeepingN has quit [Read error: Connection reset by peer]
SeepingN has joined #ruby
sameerynho has joined #ruby
fphilipe_ has joined #ruby
ellcs1 has joined #ruby
<yann-kaelig>
thx, cu
yann-kaelig has quit [Quit: yann-kaelig]
<leitz>
yann-kaelig, sometimes the Gemspec or the page on Rubygems.org will have the GitHub or other site.
<leitz>
That way you can look at the actual code.
cthulchu_ has quit [Read error: Connection reset by peer]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
SeepingN has quit [Read error: Connection reset by peer]
cats has quit [Ping timeout: 258 seconds]
SeepingN has joined #ruby
dviola has joined #ruby
cats has joined #ruby
SeepingN has quit [Read error: Connection reset by peer]
SeepingN has joined #ruby
connor_goodwolf has quit [Ping timeout: 246 seconds]
iNs has quit [Remote host closed the connection]
iNs has joined #ruby
reber has quit [Remote host closed the connection]
ellcs1 has quit [Ping timeout: 264 seconds]
tpanarch1st has joined #ruby
ramfjord has quit [Ping timeout: 245 seconds]
ellcs1 has joined #ruby
SCHAPiE has quit [Ping timeout: 245 seconds]
bambanx has joined #ruby
cthulchu_ has joined #ruby
ellcs1 has quit [Ping timeout: 264 seconds]
bambanx has quit [Max SendQ exceeded]
sameerynho has quit [Ping timeout: 244 seconds]
elphe has joined #ruby
SCHAPiE has joined #ruby
drip has joined #ruby
drip is now known as amateur_rubyist
dinfuehr has quit [Ping timeout: 245 seconds]
jenrzzz_ has quit [Ping timeout: 244 seconds]
dinfuehr has joined #ruby
<amateur_rubyist>
Hi - I've recently joined a coding bootcamp, and we've been given a challenge (I'm not here to 'game' the challenge), but I've seemed to have reached a point that I can't move beyond and would appreciate some help to resolve the error.
<ruby[bot]>
amateur_rubyist: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
<havenwood>
amateur_rubyist: What's the error you're running into?
<amateur_rubyist>
I'm just typing out some context, or would you rather I get into the error?
<havenwood>
amateur_rubyist: One thing I spot up front is that it seems odd for #in_journey? to modify @in_journey.
<havenwood>
amateur_rubyist: I would have expected: def in_journey?; @in_journey end
greengriminal has quit [Quit: Leaving]
<havenwood>
amateur_rubyist: Context or error are both great. Whichever first!
<amateur_rubyist>
should I direct message you?
jenrzzz has joined #ruby
<havenwood>
amateur_rubyist: To the channel is fine. However you prefer.
<havenwood>
amateur_rubyist: It doesn't seem right to have an attr_reader for #top_up.
<havenwood>
There's no @top_up instance variable.
<leitz>
If a hash is built from a JSON file, the hash then uses strings, not symbols, correct?
<havenwood>
leitz: You can use the `symbolize_names: true` keyword with JSON.parse.
* leitz
goes off to check that out.
* leitz
returns quickly, with success.
<amateur_rubyist>
Essentially what I've been asked to do is for the Oystercard instance to default false, as indicated by the in_journey? predicate method
<amateur_rubyist>
when you 'tap_in', this should change to true, as you are now on a journey
<amateur_rubyist>
conversely, if you `tap_out`, the journey has ended, and @in_journey would change to false
cthulchu_ has quit [Ping timeout: 245 seconds]
<amateur_rubyist>
So I've written the rspec test, to test that when I tap_in (i.e. commence a journey) that this toggles the @in_journey instance var, to `true`, but this test seems to be failing
<amateur_rubyist>
Any ideas on how I can pass this test?
<amateur_rubyist>
The challenge is adamant that I have these three methods (in_journey?, tap_in, tap_out) in the program, so I'm not allowed to refactor (not right now anyway)
<havenwood>
amateur_rubyist: Have you tried again after fixing #in_journey?
ramfjord has joined #ruby
<havenwood>
amateur_rubyist: (It shouldn't set @in_journey, just return it.)
<havenwood>
amateur_rubyist: Change the content of #in_journey? to just: @in_journey
<havenwood>
amateur_rubyist: Does that make sense?
<havenwood>
(The method currently only returns `false`.)
<amateur_rubyist>
Brilliant, it works
<amateur_rubyist>
Could you explain where I went wrong?
<amateur_rubyist>
As in, the logic behind why my test was failing?
<havenwood>
amateur_rubyist: The method is meant to return the @in_journey value. As you had it, it was instead setting @in_journey to false, and returning false.
<leftylink>
notice now lines 23 and 31 were exactly the same
<leftylink>
which implies that #in_journey? was doing exactly the same thing as #touch_out
<leftylink>
which should seem weird.
<leftylink>
because as the English description of those two functions went, they should not do the same thing
<amateur_rubyist>
okay, but in the instance of the tap_in test, wouldnt this toggle the @in_journey to `true`, overriding the `false` value?
<amateur_rubyist>
in the instance of the tap_in test, wouldn't the tap_in method toggle**
<leftylink>
sure. but if you tap_in, then you are in a journey, right?
tpanarch1st has quit [Ping timeout: 272 seconds]
tpanarch1st_ has joined #ruby
<leftylink>
hmm. was the rspec idiom of `expect(subject) to be_x` explained in the bootcamp so far?
<leftylink>
where `expect(subject).to be_x` calls `subject.x?`
<leftylink>
in this case, `subject.in_journey?`
<amateur_rubyist>
fleetingly - I think its a sticking point, I think my understanding of that is dodgy and is the reason why i'm slightly confused
<amateur_rubyist>
could you explain it please
<amateur_rubyist>
the rspec documentation isn't very clear, to me at least. I think what also confuses it a little is that there is also a negation used in one of the tests that also uses the `be` statement
<leftylink>
in that case, to the creators of the test I might suggest that it may be better to have the test explicitly say `expect(subject.in_journey?) to eq(true)` or something, instead of `expect(subject).to be_in_journey` . while I understand that they wanted to use the latter to be more... like English speech... it may not immediately be obvious that it is causing `subject.in_journey?` to be called
jenrzzz has quit [Ping timeout: 272 seconds]
<amateur_rubyist>
The `eq` version of the statement was what I initially gravitated towards, but it seems they wanted it done using the `be` syntax
<leftylink>
`For any predicate method, RSpec gives you a corresponding matcher. Simply prefix the
<leftylink>
method with be_ and remove the question mark`
jenrzzz has joined #ruby
<leftylink>
so that is the logic behind doing it with `be`. if the creators of the test say that the test must be written with `be_X` then it may be good to link that documentation
SeepingN has quit [Quit: The system is going down for reboot NOW!]
<amateur_rubyist>
so if in_journey? is false, and I do: expect(subject).to be_in_journey -- under what circumstances will the test pass?
sagax has joined #ruby
<leftylink>
if in_journey? is false and you do `expect(subject).to be_in_journey`, then the test will certainly fail. cine it expects `in_journey?` to be true.
involans has quit [Quit: involans]
<leftylink>
s/cine/since/
<amateur_rubyist>
so it generally tests for the predicate to be true? unless you use not_to after the subject?
Frobozz has quit [Ping timeout: 245 seconds]
ellcs1 has joined #ruby
fphilipe has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
<amateur_rubyist>
@leftylink - thanks, I think i've got it. `be` returns the predicates. `to be` passes the test if the predicate returns true. `not_to be` passes if the predicate is `false`.
<amateur_rubyist>
The examples in question essentially do the following call: subject.in_journey?. I was going wrong earlier because I was hardcoding @in_journey = false, inside the in_journey? predicate
<amateur_rubyist>
I think this is a correct assessment, unless someone else thinks otherwise
<amateur_rubyist>
Thanks again
poontangmessiah has quit [Remote host closed the connection]